Hi experts, I have a strange error in my user creation script. When I generate a ADS user object and write it to the ADS, .setinfo returns error -2147352567 (ConvertCOMError translates it to "the storage control block is invalid") BUT the user object gets created! Can anybody tell me what I'm doing wrong? At the moment, I continue with the script ignoring this error, but this can only be a workaround...

Here's the fragment of my script (most of the parts borrowed from this source anyway)

Function AddUser($NotesID, $UserOU, $Givenname, $Surname)
DIM $AdsDomain, $AdsUser, $NORMAL_ACCOUNT, $DisplayName
$NORMAL_ACCOUNT = &0200
;
Debug on
$AdsDomain = GetObject("LDAP://" + $UserOU)
If $AdsDomain=0
ConvertCOMError(@ERROR)
$AddUser = "Error occured during AddUser: " @SERROR
EndIf
$DisplayName = $Givenname + " " + $Surname
$AdsUser = $AdsDomain.Create("user","cn=" + $DisplayName)
If $AdsUser = 0
$AddUser = "Unable to create user $NotesID"
Return
EndIf

$adsUser.Put("sAMAccountName", $NotesID)
$adsUser.Put("userPrincipalName", $NotesID + "@@EMEA.globalcsc.net")
$adsUser.Put("givenName", $Givenname)
$adsUser.Put("sn", $Surname)
$adsUser.Put("displayName", $DisplayName)
$adsUser.Put("HomeDirectory","\\cscdssbrn001.ch.emea.csc.com\" + $NotesID + "$")
$adsUser.Put("homeDrive", "I:")
$adsUser.Put("Description","User created by " + @USERID + " with script " + @SCRIPTNAME)

;Write the newly created object out from the property cache
$adsUser.SetInfo
If not @ERROR = 0
ConvertCOMError(@ERROR)
$AddUser = "Error occured during AddUser: " @SERROR
Return
EndIf
....
EndFunction

Thanks for you help!