Link to home
Start Free TrialLog in
Avatar of zonkerman
zonkermanFlag for United States of America

asked on

How can I get a list of groups in Active Directory and find out who is in those groups

I would like to be able to find out the names of all the active directory groups in my company and who is in those groups.  How would I do this using Visual Studio 2005 Visual Basic and .NET 2.0?   I tried with the below sample code but specifying "ou=Groups" does not do anything.  If I use something in the filter like sn=mar* then I do get the proper listing of names for the wildcard.  Maybe I should be using something other than "ou=" to find the groups?  I need a solution that uses VS 2005 Visual Basic and .NET 2.0

        Dim aADE As New DirectoryEntry("LDAP://myADNodePath")
        Dim aDS As New DirectorySearcher(aADE)
        Dim aSearchResult As SearchResult
        aDS .Filter = ("(ou=Groups)") '
        Dim aSRC As SearchResultCollection
        aSRC = aDS .FindAll()

        For I1 As Integer = 0 To aSRC .Count - 1
            aSearchResult = aSRC .Item(I1)
            ListBox1.Items.Add(aSearchResult.Path)
        Next
SOLUTION
Avatar of Zavatar
Zavatar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of AkisC
AkisC
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial