pshankland
Programmer
Hi,
I am trying to get a script working that will modify the description and profile server of a given user within AD. Currently I have the following:
'=================================================
Const ADS_SCOPE_SUBTREE = 2
strClockCard = InputBox("Enter Clock Card Number:")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://DC=RICOH-RPL,DC=COM' WHERE objectClass='user' " & "and sAMAccountName = '" & strClockCard & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set objDistinguishedName = objRecordSet.Fields("distinguishedName").Value
Set objExistingUser = GetObject("LDAP://" & objDistinguishedName)
objExistingUser.Put "profilePath", strProfileServer & "\Profiles\" & strClockCard
objExistingUser.Put "description", strClockCard
objExistingUser.SetInfo
'=================================================
Whenever I run this I get the following error:
Object required: '[string: "CN=test1,OU=TEST,OU="]'
Anyone got any ideas as am a bit stuck now!
Thanks.
Pete.
I am trying to get a script working that will modify the description and profile server of a given user within AD. Currently I have the following:
'=================================================
Const ADS_SCOPE_SUBTREE = 2
strClockCard = InputBox("Enter Clock Card Number:")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://DC=RICOH-RPL,DC=COM' WHERE objectClass='user' " & "and sAMAccountName = '" & strClockCard & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set objDistinguishedName = objRecordSet.Fields("distinguishedName").Value
Set objExistingUser = GetObject("LDAP://" & objDistinguishedName)
objExistingUser.Put "profilePath", strProfileServer & "\Profiles\" & strClockCard
objExistingUser.Put "description", strClockCard
objExistingUser.SetInfo
'=================================================
Whenever I run this I get the following error:
Object required: '[string: "CN=test1,OU=TEST,OU="]'
Anyone got any ideas as am a bit stuck now!
Thanks.
Pete.