Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set rootDSE = GetObject("LDAP://RootDSE")
- base = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">"
- sfilter = "(&(objectClass=user)(objectCategory=Person))"
- attr = "samaccountname,memberof"
- scope = "subtree"
- Set conn = CreateObject("ADODB.Connection")
- conn.Provider = "ADsDSOObject"
- conn.Open "Active Directory Provider"
- Set cmd = CreateObject("ADODB.Command")
- Set cmd.ActiveConnection = conn
- cmd.Properties("Page Size") = 1000
- cmd.CommandText = base & ";" & sfilter & ";" & attr & ";" & scope
- Set rs = cmd.Execute
- Do Until rs.EOF
- WScript.Echo rs.Fields(0).Value & ":"
- If IsNull(rs.Fields(1).Value) Then
- WScript.Echo "(memberof attribute empty)"
- Else
- For Each singleGroup In rs.Fields(1).Value
- WScript.Echo singleGroup
- Next
- End If
- WScript.Echo vbCrLf
- rs.MoveNext
- Loop
- rs.Close
- conn.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement