ASP to LDAP - try this ...



If you call DirectoryEntry with hardcoded password ("in this case
"password")- this will work but if you pass mypassword instead it will fail
Dim theusername as string ="someting", thepassword as string="somethingelse"

This is strange behavior ....

Imports System.DirectoryServices

Private Function DoYouExist(ByVal myusername As String, ByVal mypassword As
String) As Boolean

Dim entry As New DirectoryEntry(LDAP://whatever, myusername ,"password")
Dim mySearcher = New DirectorySearcher(entry)
Dim results As SearchResultCollection
Dim MySearchAccount As String = "SAMAccountName=ArchieBald"
mySearcher.Filter = (MySearchAccount)
results = mySearcher.FindAll()
Dim result As SearchResult
results = mySearcher.FindAll()
Catch ex As Exception
DoYouExist = False
Exit Function
End Try
If results.Count > 0 Then DoYouExist = True Else DoYouExist = False
End Function


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question