1

I have not been able to successfully verify a user with LDAP for an ASP.NET web application. I have done so on our own network against Active Directory, but this is against a server outside of our network that is OID (Oracle Internet Directory).

Usually, I use the following code with no problem.

Dim myDirectoryEntry As New System.DirectoryServices.DirectoryEntry("LDAP://1.2.3.4:999/OU=SomeOU,DC=Something,DC=com")
myDirectoryEntry.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Sealing
myDirectoryEntry.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Secure

Try
    myDirectoryEntry.Username = txtUserID.Text.Trim
    myDirectoryEntry.Password = txtPassword.Text.Trim

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

    mySearcher.Filter = ("(anr= " & txtUserID.Text & ")")

    Dim result As System.DirectoryServices.SearchResult = mySearcher.FindOne
Catch ex As Exception
    'failed log in handling 
End Try

For this application, I am going against a directory outside our network and the above method fails (The requested authentication method is not supported by the server.).

I can successfully bind to the LDAP server using:

Dim serverName As String = "1.2.3.4:999"

Dim dn As String = "cn=somename,cn=users,dc=something,dc=gov"

Dim ServerCon As New LdapConnection(serverName)

ServerCon.AuthType = AuthType.Basic

Dim cred As New System.Net.NetworkCredential(dn, "password")

ServerCon.Bind(cred)

After that, I haven't been able to find a method to verify a user's log in information with their password and then pull back some information.

monkeypushbutton
  • 196
  • 1
  • 9
  • 21
  • 1
    Does my answer [to this other SO question here](http://stackoverflow.com/questions/290548/c-sharp-validate-a-username-and-password-against-active-directory/499716#499716) help you at all?? – marc_s Nov 17 '11 at 16:17
  • @marc_s: Thanks, but no help (for this, but very useful for a number of other projects). The app is going against OID, not Active Directory. I'll edit the question to include this. – monkeypushbutton Nov 17 '11 at 20:07

1 Answers1

0

It might be that the server does not support Kerberos authentication. The directory server must return the error code you received in a response when the authentication method that was requested is not supported, and the authentication state of the connection cannot be set. This could happen with an unsupported SASL mechanism; the support SASL mechanisms should be listed in the root DSE.

Terry Gardner
  • 10,957
  • 2
  • 28
  • 38