We use code similar to the following to setup a secure connection to an LDAP directory:
using (LdapConnection con = new LdapConnection(new LdapDirectoryIdentifier(ConfigReader.ADServer, 636)))
{
con.SessionOptions.SecureSocketLayer = true;
con.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
con.Credential = new NetworkCredential(UserDN, UserPwd);
con.AuthType = AuthType.Basic;
con.Bind();
}
During testing, we noticed the following expected behavior:
Unfortunately, we also noticed the following unexpected behavior:
Please advise why the LDAP connection is successful with a blank password.
Thanks,
It seems like the connection is bound but is not authenticated till a actual request is sent.
Consider the following to send the request after binding the connection...
using (LdapConnection con = new LdapConnection(new LdapDirectoryIdentifier(ConfigReader.ADServer, 636)))
{
con.SessionOptions.SecureSocketLayer = true;
con.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
con.Credential = new NetworkCredential(UserDN, UserPwd);
con.AuthType = AuthType.Basic;
con.Bind();
**con.SendRequest(new SearchRequest(targetLocation, "(objectClass=*)", System.DirectoryServices.Protocols.SearchScope.Subtree, null));**
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With