Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set rootDSE = GetObject("LDAP://RootDSE")
  2.  
  3. base    = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">"
  4. sfilter = "(&(objectClass=user)(objectCategory=Person))"
  5. attr    = "samaccountname,memberof"
  6. scope   = "subtree"
  7.  
  8. Set conn = CreateObject("ADODB.Connection")
  9. conn.Provider = "ADsDSOObject"
  10. conn.Open "Active Directory Provider"
  11. Set cmd = CreateObject("ADODB.Command")
  12. Set cmd.ActiveConnection = conn
  13. cmd.Properties("Page Size") = 1000
  14. cmd.CommandText = base & ";" & sfilter & ";" & attr & ";" & scope
  15.  
  16. Set rs = cmd.Execute
  17. Do Until rs.EOF
  18.  
  19.     WScript.Echo rs.Fields(0).Value & ":"
  20.  
  21.     If IsNull(rs.Fields(1).Value) Then
  22.         WScript.Echo "(memberof attribute empty)"
  23.     Else
  24.         For Each singleGroup In rs.Fields(1).Value
  25.             WScript.Echo singleGroup
  26.         Next
  27.     End If
  28.  
  29.     WScript.Echo vbCrLf
  30.     rs.MoveNext
  31.  
  32. Loop
  33. rs.Close
  34.  
  35. conn.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement