Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Retrieves all attributes for the specified computer object.
- Set WshShell = CreateObject("WScript.shell")
- Set objEnv = WshShell.Environment("Process")
- Set args = Wscript.Arguments
- strComputerName = WScript.Arguments.Item(0)
- strSiteCode = WScript.Arguments.Item(1)
- strEmployeeID = Mid(strComputerName,2,7)
- strSysDivision = WScript.Arguments.Item(2)
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Set conn1 = CreateObject("ADODB.Connection")
- Set objCommand1 = CreateObject("ADODB.Command")
- conn1.Provider = "ADsDSOObject"
- conn1.Open "ADs Provider"
- Set objCommand1.ActiveConnection = conn1
- objCommand1.Properties("Page Size") = 1000
- objCommand1.Properties("Searchscope") = ADS_SCOPE_SUBTREE
- objCommand1.CommandText="<LDAP://URL" & ">;(&(objectcategory=computer)(Name="&strComputerName&"));adspath;subtree"
- Set rs1 = objCommand1.Execute
- Set objComputer = GetObject(rs1.Fields(0).Value)
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Set conn = CreateObject("ADODB.Connection")
- Set objCommand = CreateObject("ADODB.Command")
- conn.Provider = "ADsDSOObject"
- conn.Open "ADs Provider"
- Set objCommand.ActiveConnection = conn
- objCommand.Properties("Page Size") = 1000
- objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
- objCommand.CommandText="<LDAP://URL" & ">;(&(objectCategory=person)(objectClass=user)(employeeid="&strEmployeeID&"));adspath;subtree"
- Set rs = objCommand.Execute
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- While Not rs.EOF
- Set Userobject = GetObject(rs.Fields(0).Value)
- userdn=UserObject.distinguishedName
- Userobject.Put "extensionattribute8","test"
- Userobject.SetInfo
- If (Instr(userdn,"OU=Admin") > 1) Then
- else
- ManagedByUser=Userobject.distinguishedName
- UserObject=NULL
- End If
- rs.movenext
- Wend
- rs.close
- conn.close
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- On error resume next
- objComputer.Put "ManagedBy",ManagedByUser
- objComputer.SetInfo
- objComputer.Put "extensionattribute1" , strSiteCode
- objComputer.SetInfo
- objComputer.Put "employeeId" , strEmployeeID
- objComputer.SetInfo
- On error resume next
- objComputer.Put "Division" , strSysDivision
- objComputer.SetInfo
- rs1.close
- conn1.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement