I had already seen the last two links you mentioned. I am probably missing something, but the crux of my problem appears to be that I can't make 9 mean anything in the land of ADSI errors.
In the trapping ADSI error example, I can never get the error facility to return a code that can be found on the tables you mention in your other two links. In that example it could return &H800708B0 (the error I would expect), but I am unable to get it to return such (either utilizing decimal or hexadecimal values).
Maybe my method is bad? Here's the code I use to create the user...
Code:
$sFirst = "First"
$sLast = "Last"
$sUserID = "Test"
$NewUserOU = "whatever you want your OU to be"
$LDAP = GetObject("LDAP://" + @LDomain)
$LDAP_ADSPath = Substr($LDAP.ADSPath,Len(@LDomain) + 9,Len($LDAP.ADSPath) - Len(@LDomain))
$Cnt = 1
$FQDN1 = Split($LDAP_ADSPath,",")
For Each $Element in $FQDN1
$FQDN = $FQDN + Substr($Element,4,Len($Element) - 3) + "."
$Cnt = $Cnt + 1
Next
$FQDN = Substr($FQDN,1,Len($FQDN) - 1)
$FullName = "cn=" + $sLast + "\, " + $sFirst
$LDAP1 = GetObject("LDAP://" + $NewUserOU)
$NewUser = $LDAP1.Create("user",$FullName)
$NewUser.Put("samAccountName",$sUserID)
$NewUser.Put("sn",$sLast)
$NewUser.Put("givenName",$sFirst)
$PrincipalName = $sUserID + "@@" + $FQDN
$NewUser.Put("userPrincipalName",$PrincipalName)
$NewUser.Put("displayName",$sLast + ", " + $sFirst)
$ = $NewUser.SetInfo()
If @Error < 0
$NewUserError = Val("&" + Right(DecToHex(@Error),4))
EndIf
$ = MessageBox($NewUserError,"NewUser Error")
Thanks for your help!