Reputation: 23
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?
Upvotes: 2
Views: 1379
Reputation: 449
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.
Upvotes: 1