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..)
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