james_martin
asked on
VB.NET WinForm Fill List View with AD Users
I have already got my List View to populate with users from AD, the problem is that I am trying to limit what shows in that list view.
Example: A person choosed A-F and then clicks show and it shows all users with a username that starts with A-F.
Example: A person choosed A-F and then clicks show and it shows all users with a username that starts with A-F.
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
Dim dirEntry As DirectoryEntry = New DirectoryEntry("LDAP://10.10.10.235/CN=Users,DC=domain,DC=com")
dirEntry.Username = "domain\administrator"
dirEntry.Password = "password"
If lbxSelectUser.Items.Count > 1 Then
MsgBox("Patience Is Not 1 of your virtues")
Else
Dim mySearcher As New DirectorySearcher(dirEntry)
mySearcher.Filter = "(&(objectClass=User)(objectCategory=person))"
For Each resEnt As SearchResult In mySearcher.FindAll()
lbxSelectUser.Items.Add(resEnt.Properties("sAMAccountName")(0).ToString())
Next
lbxSelectUser.Sorted = True
End If
End Sub
James, in this situation what I would think of doing is placing all the AD info into a DATASET first; and use DATAVIEWS to populate your ListView. That way you can use simple SQL like syntac for the DATAVIEW FILTER.
ASKER
The problem with this is that it will take a lot of time to list this out, over 10,000 users. The purpose of breaking it out is to cut down on time to pull information.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CodeCruiser's suggestion sounds like a good idea if you are only going to query a small subset once or twice at a time. If you are going to do multiple searches then the initial time to build the dataset is, in my opinion, more economical.