Re: Script to add computers in the "Log On to" field of a user account
- From: "Marcin" <marcin@xxxxxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 20:31:22 -0500
The following should accomplish what you need:
Const ADS_SCOPE_ONELEVEL = 1
Set oConn = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConn.Provider = "ADsDSOObject"
oConn.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConn
oCommand.Properties("Page Size") = 1000
oCommand.Properties("Searchscope") = ADS_SCOPE_ONELEVEL
sOU = "'LDAP://ou=Workstations,dc=domain,dc=com'"
sWorkstations = ""
oCommand.CommandText = "SELECT Name, ADsPath FROM " & sOU & _ " WHERE objectCategory ='computer'" Set oRecordSet = oCommand.Execute
oRecordSet.MoveFirst
Do Until oRecordSet.EOF
If sWorkstations = "" Then sWorkstations = oRecordSet.Fields("Name").Value
Else
sWorkstations = sWorkstations & "," & oRecordSet.Fields("Name").Value
End If
oRecordSet.MoveNext
Loop
Set oGroup = GetObject("LDAP://cn=ChangeMe,ou=Groups,dc=domain,dc=com")
For Each oUser in oGroup.Members
oUser.Put "userWorkstations", sWorkstations
oUser.SetInfo
Next
hth
Marcin
.
- Prev by Date: creating Power Users
- Next by Date: Re: creating Power Users
- Previous by thread: creating Power Users
- Next by thread: Re: allowing users to manage share folders
- Index(es):