Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Retrieves all attributes for the specified computer object.
  2.  
  3. Set WshShell = CreateObject("WScript.shell")
  4. Set objEnv = WshShell.Environment("Process")
  5.  
  6.  
  7.  
  8. Set args = Wscript.Arguments
  9.  
  10. strComputerName = WScript.Arguments.Item(0)
  11. strSiteCode = WScript.Arguments.Item(1)
  12. strEmployeeID = Mid(strComputerName,2,7)       
  13. strSysDivision = WScript.Arguments.Item(2)
  14.  
  15.  
  16.  
  17. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  18. Set conn1 = CreateObject("ADODB.Connection")
  19. Set objCommand1 =   CreateObject("ADODB.Command")
  20. conn1.Provider = "ADsDSOObject"
  21. conn1.Open "ADs Provider"
  22. Set objCommand1.ActiveConnection = conn1
  23. objCommand1.Properties("Page Size") = 1000
  24. objCommand1.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  25. objCommand1.CommandText="<LDAP://URL" & ">;(&(objectcategory=computer)(Name="&strComputerName&"));adspath;subtree"
  26. Set rs1 = objCommand1.Execute
  27. Set objComputer = GetObject(rs1.Fields(0).Value)
  28.  
  29. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  30. Set conn = CreateObject("ADODB.Connection")
  31. Set objCommand =   CreateObject("ADODB.Command")
  32. conn.Provider = "ADsDSOObject"
  33. conn.Open "ADs Provider"
  34. Set objCommand.ActiveConnection = conn
  35. objCommand.Properties("Page Size") = 1000
  36. objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  37. objCommand.CommandText="<LDAP://URL" & ">;(&(objectCategory=person)(objectClass=user)(employeeid="&strEmployeeID&"));adspath;subtree"
  38. Set rs = objCommand.Execute
  39. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  40.  
  41. While Not rs.EOF
  42. Set Userobject = GetObject(rs.Fields(0).Value)
  43. userdn=UserObject.distinguishedName
  44.  
  45. Userobject.Put "extensionattribute8","test"
  46. Userobject.SetInfo
  47.  
  48. If (Instr(userdn,"OU=Admin") > 1) Then
  49. else
  50. ManagedByUser=Userobject.distinguishedName
  51. UserObject=NULL
  52. End If
  53. rs.movenext
  54. Wend
  55. rs.close
  56. conn.close
  57.  
  58. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  59.  
  60. On error resume next
  61. objComputer.Put "ManagedBy",ManagedByUser
  62. objComputer.SetInfo
  63.  
  64. objComputer.Put "extensionattribute1" , strSiteCode
  65. objComputer.SetInfo
  66. objComputer.Put "employeeId" , strEmployeeID
  67. objComputer.SetInfo
  68.  
  69. On error resume next
  70. objComputer.Put "Division" , strSysDivision
  71. objComputer.SetInfo
  72.  
  73. rs1.close
  74. conn1.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement