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:
- Valid UserDN and valid UserPwd results in successful Bind()
- Invalid UserDN with a valid UserPwd results in Bind() error (The supplied credential is invalid.)
- Invalid UserDN with a Invalid (non-blank) UserPwd results in Bind() error (The supplied credential is invalid.)
Unfortunately, we also noticed the following unexpected behavior:
- Valid UserDN and blank UserPwd results in successful Bind()
- Invalid UserDN and blank UserPwd results in successful Bind()
Please advise why the LDAP connection is successful with a blank password.
Thanks,
LDAP://192.168.1.100:389/ou=People,dc=company,dc=comdo i need to specify port number ? do i need to prefix with ldap ?