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.
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click

        Dim dirEntry As DirectoryEntry = New DirectoryEntry("LDAP://,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")
            Dim mySearcher As New DirectorySearcher(dirEntry)
            mySearcher.Filter = "(&(objectClass=User)(objectCategory=person))"
            For Each resEnt As SearchResult In mySearcher.FindAll()
            lbxSelectUser.Sorted = True
        End If
    End Sub

Open in new window

Who is Participating?
CodeCruiserConnect With a Mentor Commented:
You can make up the SearchFilter string like below

sn=a* (all names starting with a)
(sn=a*)(sn=b*) (all names starting with a or b)

Check here
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.
james_martinAuthor Commented:
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.
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.  
All Courses

From novice to tech pro — start learning today.