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)
Who is Participating?

Improve company productivity with a Business Account.Sign Up

AkisCConnect With a Mentor Commented:
       Dim strDomain As String = "", tmp As String = ""
        Dim Computer As Object, Group As Object
        Computer = GetObject("WinNT://" & strDomain)
        For Each Group In Computer
            If (Group.Class = "Group") Then
                tmp &= Group.Name & vbCrLf
            End If
ZavatarConnect With a Mentor Commented:
Try objectClass=group
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.