Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify an Active Directory User

Status
Not open for further replies.

pshankland

Programmer
Jul 9, 2001
57
GB
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.

 
>Set objDistinguishedName = objRecordSet.Fields("distinguishedName").Value
It is a simple string (named obj... is self-misleading).
[tt]objDistinguishedName = objRecordSet.Fields("distinguishedName").Value[/tt]

>objExistingUser.Put "description", strClockCard
It is multi-valued property.
[tt]objExistingUser.PutEx 2, "description", array(strClockCard) 'ADS_PROPERTY_UPDATE=2[/tt]
 
It woudl appear you have not posted all of your code. WHere ae you setting the value of objDistinguishedName?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top