Question Locked

AD how to get a listing of security groups?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am having to trawl through the properties and security groups and then type out each individual group. Is there an easy way to do this that i could employ. If anyone can help i would be a very happy bunny!

3 replies

by fred123456

As far as I know your going to have write a VB script that will enumerate through the groups container and then list each memeber of the group.

For example:
Option Explicit
Dim objRootLDAP, objGroup, objUser, objOU, objmemberOf
Dim strOU, strUser, strDNSDomain, strLDAP, strList

' Commands to bind to AD and extract domain name
Set objRootLDAP = GetObject("LDAP://RootDSE")
strDNSDomain = objRootLDAP.Get("DefaultNamingContext")

' Build the LDAP DN from strUser, strOU and strDNSDomain
strUser ="cn=Administrator,"
strOU ="CN=Users,"
strLDAP ="LDAP://" & strUser & strOU & strDNSDomain

Set objUser = GetObject(strLDAP)

' Heart of the script, extract a list of Groups from memberOf
objmemberOf = objUser.GetEx("memberOf")
For Each objGroup in objmemberOf
strList = strList & objGroup & vbcr
Next

WScript.Echo "Groups for " & strUser & vbCr & strList

WScript.Quit

' End of Sample User memberOf VBScript

This discussion is closed to new replies.