Modify user - LDAP (VBScript)
This code can be found in
Chapter 23 of Active Directory, 3rd Edition
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' From the book "Active Directory, Third Edition"
' ISBN: 0-596-10173-2
Option Explicit
On Error Resume Next
Dim objConn, objComm, objRS, objUser
Dim strBase, strFilter, strAttrs, strScope
'**********************************************************************
'Set the ADO search criteria
'**********************************************************************
strBase = "<LDAP://dc=mycorp,dc=com>;"
strFilter = "(&(objectclass=user)(objectcategory=person)(department=Sales));"
strAttrs = "ADsPath;"
strScope = "Subtree"
set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open
'**********************************************************************
'Need to enable Paging in case there are more than 1000 objects returned
'**********************************************************************
Set objComm = CreateObject("ADODB.Command")
Set objComm.ActiveConnection = objConn
objComm.CommandText = strBase & strFilter & strAttrs & strScope
objComm.Properties("Page Size") = 1000
Set objRS = objComm.Execute()
While not objRS.EOF
Set objUser = GetObject( objRS.Fields.Item("ADsPath").Value )
objUser.LoginScript = "login-sales.vbs"
objUser.SetInfo
if Err.Number <> 0 Then
Wscript.Echo objUser.Name & " error occurred"
Err.Clear
Else
Wscript.Echo objUser.Name & " modified"
End if
objRS.MoveNext
Wend
|
This code has been viewed 5034 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|