2

Trying to authenticate through ldap using LdapDirectoryIdentifier to communicate to an openldap server.

Code snippet

dapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("ldap.com", 636);
LdapConnection lconn = new LdapConnection(ldi);
lconn.SessionOptions.ProtocolVersion = 3;
lconn.Bind();
lconn.Dispose();

Running the code gives me an exception at Bind() stating LDAP server is not available. But upon reviewing my netstat, the connection is there and established. There are no other error messages available.

Any idea?

1 Answer 1

1

Port 636 is for SSL. Try directly with LdapConnection to make sure you can access that server via SSL (SecureSocketLayer = true):

using (var ldapConnection = new LdapConnection("my.ad.server:636")) {
                    var networkCredential = new NetworkCredential(username, password, "my.ad.server");
ldapConnection.SessionOptions.SecureSocketLayer = true;
                    ldapConnection.AuthType = AuthType.Negotiate;
                    ldapConnection.Bind(networkCredential);
                }

See if this works.

Sign up to request clarification or add additional context in comments.

1 Comment

This was partially the answer. There was also no certificate so I had to circumvent that using lconn.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, ver) => true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.