IRa
(Fresh Scripter)
2003-09-09 09:22 AM
.PutEx

Anyone have a clue on this?

Trying to PutEx an extra E-mail address in Exchange as follows:

code:
$Server="Serverx"
$Site="Sitex"
$User="Userx"
$Org="Orgx"

$UserDN="$Server/CN=$User,CN=Recipients,OU=$Site,o=$Org"

$ObjUser=GetObject("LDAP://$UserDN")

Dim $NewMail[1]
$NewMail[0]="smtp$$xx@@test.com"
$ObjUser.PutEx(3,"otherMailbox",$NewMail) @Error ?

$ObjUser.SetInfo @Error ?

$ObjUser.PutEx returns "1"
$ObjUser.SetInfo returns "0"

Why does the PutEx fail?
Any thoughts welcome

[ 09. September 2003, 14:23: Message edited by: Chris S. ]


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 10:44 AM
Re: .PutEx

fail with what error code?

IRa
(Fresh Scripter)
2003-09-09 10:52 AM
Re: .PutEx

"$ObjUser.PutEx" fails with a returncode of "1"
"$ObjUser.SetInfo" suceeds with a returncode of "0"

IADs::PutEx syntax: PutEx(Long, BStr, Variant)

Could the "Long" or "BStr" be the problem (all Kix variables = Variant) ?


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 10:59 AM
Re: .PutEx

I would try this simple change to your line:
code:
$ObjUser.PutEx(3,"otherMailbox",$NewMail[0]) @Error ?

anyway, I must wonder.
objects about never give real errors.
this says it straight though. it doesn't like PutEx


IRa
(Fresh Scripter)
2003-09-09 11:27 AM
Re: .PutEx

No, dosn't work either - returns "1".

I tried this:

code:
$Server="Serverx"
$Site="Sitex"
$User="Userx"
$Org="Orgx"

$UserDN="$Server/CN=$User,CN=Recipients,OU=$Site,o=$Org"

$ObjUser=GetObject("LDAP://$UserDN")

$OMailbox=$ObjUser.GetEx("otherMailbox")
$IMax=UBound($oMailbox) $IMax ?
ReDim Preserve $oMailbox[$IMax]
$oMailbox[$IMax]="smtp$$xx@@test.dk"

$ObjUser.PutEx(2,"otherMailbox",$oMailbox) @Error ?

Epl.: Retreiving the original E-Mail Addresses Array, and adding the New Mail Address, then replacing the whole thing with PutEx(2,...).

This is accepted (returncode 0), however in Exchange the added E-Mail Address is listed as: ???????k (with no message type).

Logging reveals:
"LDAP modify request contains value CCMAIL$Test, Userx at Sitex."
"LDAP modify request contains value MS$Orgx/Sitex/Userx."
"LDAP modify request contains value 浳灴砤䁸整瑳搮k."

From last log line it appears there are somthing wrong in the valuetype passed

What on earth...

[ 09. September 2003, 14:22: Message edited by: Chris S. ]


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 11:32 AM
Re: .PutEx

ok, can I ask you from now start using the code-tags when you post code.
it rather hard to find your comments in the midst [Wink]

ok, how come you assume or know the putEx takes the e-mail addy as array?

anyway, this:
code:
$OMailbox=$ObjUser.GetEx("otherMailbox")
$IMax=UBound($oMailbox) $IMax ?
ReDim Preserve $oMailbox[$IMax]
$oMailbox[$IMax]="smtp$$xx@@test.dk"

seems to me just the same as:
code:
$OMailbox=$ObjUser.GetEx("otherMailbox")
$oMailbox[UBound($oMailbox)]="smtp$$xx@@test.dk"



IRa
(Fresh Scripter)
2003-09-09 11:50 AM
Re: .PutEx

1. I base the assumption on several VBS codesamples, here is one from the ADSI SDK:
quote:
x.PutEx ADS_PROPERTY_APPEND, "OtherhomePhone", Array("333-3333")
2. Your right, it appears the same, however some difference must exist in the stored string format, as the first 2 elements in the array are accepted and the third appears as garbage.

I guess getting the array preserves the stringformat if you don't mess with it.

Listing the VarType() for each element gives 8 (string) for all elements, including the added one (Ruud?).

Sorry obout the quoting


IRa
(Fresh Scripter)
2003-09-09 11:53 AM
Re: .PutEx

Sorry again

Answer to your second question:

2. Yes it's the same (and generates same error)


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 11:59 AM
Re: .PutEx

could you try with this piece and say does they all look  -

code:
$ObjUser=GetObject("LDAP://"+$Server+"/CN="+$User+",CN=Recipients,OU="+$Site+",o="+$Org)
$oMailbox=$ObjUser.GetEx("otherMailbox")

"mailbox before change:"
for each $value in $oMailbox
? $value
next
$oMailbox[UBound($oMailbox)]="smtp$$xx@@test.dk"
? ? "and after:"
for each $value in $oMailbox
? $value
next

not sure but think it comes to com-object arrays...
try it out but might be you need to find another way to do this [Wink]


LonkeroAdministrator
(KiX Master Guru)
2003-09-10 12:01 AM
Re: .PutEx

second question.
you mean the code?
wasn't a question [Wink]


IRa
(Fresh Scripter)
2003-09-10 12:13 AM
Re: .PutEx

Produces:
quote:
mailbox before change:
CCMAIL$Test, Test1 at Horsholm
MS$LSG/HORSHOLM/TEST1
???????k

and after:
CCMAIL$Test, Test1 at Horsholm
MS$LSG/HORSHOLM/TEST1
smtp$xx@test.dk



LonkeroAdministrator
(KiX Master Guru)
2003-09-10 12:23 AM
Re: .PutEx

ok.
then, say how this does work:
code:
$ObjUser=GetObject("LDAP://"+$Server+"/CN="+$User+",CN=Recipients,OU="+$Site+",o="+$Org)
$oMailbox=$ObjUser.GetEx("otherMailbox")
$val=$oMailbox[UBound($oMailbox)]
$oMailbox[UBound($oMailbox)]="SMTP$$xx@@test.dk"
redim preserve $oMailbox[UBound($oMailbox)+1]
$oMailbox[UBound($oMailbox)]=$val

$ObjUser.PutEx(2,"otherMailbox",$oMailbox)

btw, I see you found the quote-button [Wink]
willing to try the code-button too? [Big Grin]

[ 09. September 2003, 12:24: Message edited by: Lonkero ]


IRa
(Fresh Scripter)
2003-09-10 12:34 AM
Re: .PutEx

(Added a .SetInfo)

The PutEx is accepted. In Exchange the added address is: ???????k.

Logging reveals same garbage as before instead of proper E-mail Address.


LonkeroAdministrator
(KiX Master Guru)
2003-09-10 12:46 AM
Re: .PutEx

dude...
you could try outputting a mailbox which already has an smtp addy.
to see do we have the correct format at all.


IRa
(Fresh Scripter)
2003-09-10 12:54 AM
Re: .PutEx

Yes, already did. When failing I don't thrust books, however in this case the book format and the real life format matches. Only not the PutEx [Confused]

(found the gremlins as well)


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 01:04 PM
Re: .PutEx

k, finally bothered looking at msdn.
this is vbs sample:
quote:
objNewDL.PutEx ADS_PROPERTY_UPDATE, "otherMailbox", (aOtherMailbox)

objNewDL.Put "Report-To-Originator", True
objNewDL.Put "Report-to-Owner", False
objNewDL.Put "Replication-Sensitivity", CInt(20)
objNewDL.Put "rfc822Mailbox", CStr(strSMTPAddr)
objNewDL.Put "textEncodedORaddress", CStr(strx400Addr)
objNewDL.SetInfo


like you see, the addresses are not put in with putEx()
do you have a sample link that does it with that?


IRa
(Fresh Scripter)
2003-09-09 01:16 PM
Re: .PutEx

You have the reference in your very first line:
quote:
objNewDL.PutEx ADS_PROPERTY_UPDATE, "otherMailbox", (aOtherMailbox)

The
quote:
objNewDL.Put "rfc822Mailbox", CStr(strSMTPAddr)

sets the primary E-mail Address (return address), "otherMailbox" sets additional E-mail Addresses (and that is what I need) [Smile]


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 03:22 PM
Re: .PutEx

well, according to the documentation, the "aothermailbox" is just a bogus null.
there is nothing passed with it.


Howard Bullock
(KiX Supporter)
2003-09-09 03:34 PM
Re: .PutEx

Please review this post.

http://aspn.activestate.com/ASPN/Mail/Message/278010

Could this be part of your issue? I can put this into KiXtart terms if you believe you have the same issue.


IRa
(Fresh Scripter)
2003-09-09 04:18 PM
Re: .PutEx

LK:
The documentation is quit scarce and from time to time contradictionary and gives no insight. The working examples are the ones to learn from.

As I can GetEx "otherMailbox", it can't be all bogus. I can PutEx as well, it only, for some reason, passes garbage to the PutEx method, when I populate the elements my self, but not if I pass the previously GetEx'ed values [Confused]

HB:
Yes, it's the exact same thing I am trying to accomplish.
I'm not fluent in Perl, so your translation is appreciated.


Howard Bullock
(KiX Supporter)
2003-09-09 05:06 PM
Re: .PutEx

$NewMail[0]="smtp$$xx@@test.com"

What is "$$xx" in the above string?

Does this translate to smtp:user@test.com? I know the double @'s are correct.

The Perl example deals with the data being return as a single value or as an array if multiple values exist. In all cases the code rebuilds the array to write back to the property.

I am a little confused by your last post.

Before we get into all that thought. Do you have any existing data in this property alreadt on any mailboxes? If yes, can you succesfully extract the data? If no, can you add some data via the Exchange admin program to test reading the data?

[ 09. September 2003, 17:08: Message edited by: Howard Bullock ]


Howard Bullock
(KiX Supporter)
2003-09-09 05:20 PM
Re: .PutEx

On a test mailbox can you get the following to work to replace what is there or to add the first item?

$ObjUser.PutEx(2,"otherMailbox",$NewMail) @Error ?


Howard Bullock
(KiX Supporter)
2003-09-09 05:25 PM
Re: .PutEx

Also what version of KiXtart are you using?

Try:

Dim $NewMail[0] instead of $NewMail[1]


IRa
(Fresh Scripter)
2003-09-09 05:26 PM
Re: .PutEx

1. The E-mail Addresses (otherMailbox) syntax = smtp$user@test.com
In Kix entered as: "smtp$$user@@test.com" (tried "smtp"+"$$"+"user@@test.com" with same result).

Yes it translates to: smtp$user@test.com

2. I have existing X400, SMTP Primary, MS and CCMail addresses, and want to add one or more secondary SMTP Addresses.

3. Yes, I can sucessfully retreive the data to an array with a GetEx statement.
I can even add the same array back, as long as I dosn't add to or modify anything in the array.
[Frown]


Howard Bullock
(KiX Supporter)
2003-09-09 05:36 PM
Re: .PutEx

If you can use PutEx(2,...

You may be able to get the $oldarray,

for each item in $oldarray build a $newarray

Then PutEx(2, "otherMailbox", $newarray)


IRa
(Fresh Scripter)
2003-09-09 05:40 PM
Re: .PutEx

Tried the "Dim $NewMail[0]"

It made a difference; now the PutEx is accepted (returncode 0), however the value entered into Excange Admin is: ???????k (with no mailtype)

From logging: "LDAP modify request contains value 浳灴砤䁸整瑳搮k. "

How come $NewMail is passed as garbage?
To me it looks like ADSI is expecting a reference to the elements in the array rather then the strings itself?!

Kixtart is ver. 4.02

Running on a NT 4.0 server with ADSI Provider 2.5.
Tried running from a Win2K pro with same result.


Howard Bullock
(KiX Supporter)
2003-09-09 05:42 PM
Re: .PutEx

KiXtart 4.02 has some COM issues. Please try again with 4.21.

Have you tried using PutEx (2, ... instead putEx(3, ...?

[ 09. September 2003, 17:44: Message edited by: Howard Bullock ]


IRa
(Fresh Scripter)
2003-09-09 06:12 PM
Re: .PutEx

1. Tried Ver 4.21, and even 4.22 RC, - same result [Frown]

2. Tried PutEx(2...), it replaces first mail entry (ccmail) with: "???????k"

[Confused]


Howard Bullock
(KiX Supporter)
2003-09-09 07:15 PM
Re: .PutEx

Sorry to say I am at a loss at this point. I do not have a test exchange environment with which I can try this.

I know that GetInfoEx had problems and will be fixed in the production release of 4.22. Maybe there are some other PutEx issues as well.


In the past I was able to successfully use PutEX with Perl. So maybe this is a KiXtart issue. Can anyone get this to work with KiXtart or replicate the failure?


IRa
(Fresh Scripter)
2003-09-09 08:28 PM
Re: .PutEx

Found this at MSDN (Active Directory Services Interface in the Microsoft Exchange 5.5 Environment):

code:
Note that in VBScript, it is necessary to CStr() string values
to properly format the data for ADSI:

objNewDL.Put "cn", CStr(strDisplayName)
objNewDL.Put "uid", CStr(strAliasName)
objNewDL.Put "distinguishedName", CStr("cn=" + strAliasName +
",cn=Recipients,ou=" + strSite + ",o=" + strOrganization)
objNewDL.Put "mail", CStr(strSMTPAddr)

This code creates a multivalued property. In VBScript you have
to de-reference the array by using parentheses:

objNewDL.PutEx ADS_PROPERTY_UPDATE, "otherMailbox", (aOtherMailbox)

objNewDL.Put "Report-To-Originator", True
objNewDL.Put "Report-to-Owner", False
objNewDL.Put "Replication-Sensitivity", CInt(20)
objNewDL.Put "rfc822Mailbox", CStr(strSMTPAddr)
objNewDL.Put "textEncodedORaddress", CStr(strx400Addr)
objNewDL.SetInfo

Response.Write "DL Created Successfully!<BR><BR>"

I tried CStr'ing the E-Mail string before PuEx'ing it to no avail.

Can anyone figure out if the:
quote:
it is necessary to CStr() string values to properly format the data for ADSI
and the:
quote:
In VBScript you have to de-reference the array by using parentheses
makes an issue in Kix?


LonkeroAdministrator
(KiX Master Guru)
2003-09-09 09:06 PM
Re: .PutEx

heh, you found the very same topic I cut the code from.

but like said before, do you find the initialization of the aothermailbox in this code?
not.
there is no such var, nor even string.
so, actually this code from msdn shouldn't work either.


IRa
(Fresh Scripter)
2003-09-09 09:59 PM
Re: .PutEx

In the "Mail-Recipient (person) Object Class" Table, in the "Exchange Name" Column, is listed: "Proxy-Addresses"

The corresponding "LDAP Name" Column lists:
quote:
mail, rfc822Mailbox,OtherMailbox, textEncodedORAddress
And the corresponding "Comment" Column says:
quote:
The list of foreign mail system addresses for this recipient. This attribute is exposed as follows: Primary SMTP address - mail Primary X.400 address - textEncodedORAddress other addresses - otherMailbox
Furthermore it is used 4 times in the examples.

I agree it's wake, but it's there, and it works [Wink]

(this is the level of documentation I have come to expect, dealing with M$ technologies [Smile] )


Mark Austrin
(Lurker)
2003-09-11 05:09 AM
Re: .PutEx

I had the same issue trying to update a custom attribute for a product called DirectorySmart.

I found no way thru Kixtart to successfully use .putex, but I did come up with a work-around.

The workaround involves the creation of a temporary VBscript, and the execution of this script. See the example below:

code:
 
; this example will add 3 entries to the otherIpPhone attribute for user Jim Smith

Break ON

CLS

$phone1="phone1"
$phone2="phone2"
$phone3="phone3"

$setdn = Chr(34)+"LDAP://w2kbase.sandbox.ca/cn=Jim Smith,ou=TestOU,dc=sandbox,dc=ca"+Chr(34)

; chr(34) is double-quote

Del "c:\tempvbs.vbs"

Open(2,"c:\tempvbs.vbs",5)

WriteLine(2,"Const ADS_PROPERTY_UPDATE = 2 ")+@CRLF
WriteLine(2,"Set objUser = GetObject _")+@CRLF
WriteLine(2,"("+$setdn+")")+@CRLF
WriteLine(2,"objUser.PutEx ADS_PROPERTY_UPDATE, _")+@CRLF
WriteLine(2,Chr(34)+"otherIpPhone"+Chr(34)+", Array"+Chr(34)+"("+$phone1+Chr(34)+","+Chr(34)+$phone2+Chr(34)+","+Chr(34)+$phone3+Chr(34)+")")+@CRLF

WriteLine(2,"objUser.SetInfo")+@CRLF
Close(2)

? "Press anykey to spawn tempvbs.vbs"
Get $anykey

Shell "cmd.exe /c c:\tempvbs.vbs"

? "Done"

Get $gg


Hope this helps


LonkeroAdministrator
(KiX Master Guru)
2003-09-11 05:58 AM
Re: .PutEx

hmm...
you might want to wait on the 4.22 final of kixtart or the next RC.
there is at least one com-related bug fixed...
lets see what it does.


IRa
(Fresh Scripter)
2003-09-11 09:37 AM
Re: .PutEx

Thank's MA, it's a great suggestion.

Since I'm coding for a NT platform, it requires VBS installed, and then I might as well do the whole thing in VBS where it's known to work.

However it got around the failure; Luckily you can create an import file and import it to Exchange.

I created an importfile with the new addresses, and then made the script import the file to Exchange, - it works.

Thank's to all for chippin in.


LonkeroAdministrator
(KiX Master Guru)
2003-09-11 09:42 AM
Re: .PutEx

uhm.
did I read right.
you made the hardest thing (making of the csv) by hand and then the easy part of importing you scripted? [Eek!]


IRa
(Fresh Scripter)
2003-09-11 10:46 AM
Re: .PutEx

The whole task was; To change Exchange mail aliases and add a secondary E-mail address with the new alias, then adjust the SAM/loginname accordingly. An input file lists current an new aliases.

I did all the tasks that was possible by ADSI (LDAP:/WinNT:).

Since I could not PutEx the new E-mail addresses (as Exchange requires), the script writes them to a CSV Import file, which the script subsequently commands Exchange to import.

Best regards.


redniels
(Fresh Scripter)
2005-01-05 09:05 PM
Re: .PutEx

Just curious: when was this fixed? and what was the problem?
cause I was fighting the whole day with kix 4.21 with this same problem, and only now, at this non work hour i came up with the brilliant idea of trying it on kix 4.23.. and behold.. it works..

so.. enlighten me...what was wrong in previous versions?


Howard Bullock
(KiX Supporter)
2005-01-06 02:26 AM
Re: .PutEx

It was fixed in 4.22. See these thread for more info.

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB3&Number=79478
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB3&Number=79473
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB2&Number=76258