Hi all,
I've got to create a user account (with vbscript) in a different Forest. I know the account I'm using has the relevant permission in that Forest, but am struggling to create the object.
On the objUser.setinfo line, I get the error:
-2147016651
The server is unwilling to process the request
I suspect that the credentials are not being passed to the other forest properly (we have a trust), so it may be able to connect using my logged on credentials)
Here's my script:
I've got to create a user account (with vbscript) in a different Forest. I know the account I'm using has the relevant permission in that Forest, but am struggling to create the object.
On the objUser.setinfo line, I get the error:
-2147016651
The server is unwilling to process the request
I suspect that the credentials are not being passed to the other forest properly (we have a trust), so it may be able to connect using my logged on credentials)
Here's my script:
Code:
Const ForReading = 1, ForAppending = 8
Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_SERVER_BIND = &H200
strUser = "domain\whatever"
strPassword = "thePassword"
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = strUser
objConnection.Properties("Password") = strPassword
objConnection.Properties("Encrypt Password") = True
objConnection.Properties("ADSI Flag") = ADS_SECURE_AUTHENTICATION and ADS_SERVER_BIND
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://192.168.0.1:3268/DC=company1,DC=com>"
strAttributes = "adspath"
strFilter = "(&(distinguishedname=OU=Users,DC=Company1,DC=com))"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 500
objCommand.Properties("Timeout") = 120
objCommand.Properties("Cache Results") = True
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
For each oField in objRecordSet.Fields
set objOU = Getobject(oField.value)
Set objUser = objOU.Create("User", "cn=zzTestuser")
objUser.put "samAccountName", "testing.testing"
objUser.setinfo
Next
objRecordSet.MoveNext
Loop