Why doesn't this Search work?

esnmb

Member
Joined
Jul 12, 2005
Messages
15
Programming Experience
Beginner
The search is working, but I want the app to also tell me that the user account does NOT exist.

If the username exists in AD the app tells me, but if I put in Else in there nothing happens when I put in a garbage username.

This is what I have so far:
Dim entry As New DirectoryServices.DirectoryEntry("LDAP://OU=All Users,DC=mlnusa,DC=com")

Dim mySearcher As New System.DirectoryServices.DirectorySearcher(entry)

Dim result As System.DirectoryServices.SearchResult

mySearcher.Filter = ("(samAccountName=" & txtUserName.Text & ")")

For Each result In mySearcher.FindAll()

If result.GetDirectoryEntry().Path <> "" Then

MsgBox("Account Already Exists!" & vbCrLf & "Please choose another " _

& "username.", MsgBoxStyle.Exclamation, "Account Problem")

End If

Next

 
Back
Top