Question Why I only get a few users out of the Domain Uers list?

rgouette

Member
Joined
May 22, 2006
Messages
16
Location
Maine,USA
Programming Experience
1-3
Why I only get a few users out of the Domain Uers list?

Goal: display all users of the "Domain Users" A/D group

The following code generates only about 6 users(seemingly random domain users..)

VB.NET:
        Dim grpSearcher As New DirectorySearcher
        grpSearcher.SearchRoot = New DirectoryEntry("LDAP://DC=myDomain;DC=com")
        With grpSearcher
            .Filter = "(&(ObjectClass=Group) (CN=Domain Users))" '<<< Change the group name to suit
        End With
        Dim colGroup As ArrayList
        colGroup = New ArrayList
        Dim Members As Object = grpSearcher.FindOne.GetDirectoryEntry.Invoke("Members", Nothing) '<<< Get Members
        For Each Member As Object In CType(Members, IEnumerable) '<<< Loop thru Members
            Dim CurrentMember As New DirectoryEntry(Member) '<<< Get DirectoryEntry for user
            colGroup.Add(CurrentMember.Name.Remove(0, 3)) '<<< Add user?s CN to the array list
        Next
        colGroup.Sort() '<<< Sort by ascending
        For Each item In colGroup
            lbUsers.Items.Add(item)
        Next
 
I don't know if this will help or not, but I had to do the .PageSize on your grpSearcher because it was limiting my searches. Although my code without that returned a LOT more users than six, so this may not help you at all.

VB.NET:
grpSearcher.PageSize = 5
 
Back
Top