我们使用类似于以下内容的代码来建立与LDAP目录的安全连接:
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();
}
在测试期间,我们注意到以下预期行为:
不幸的是,我们还注意到以下意外行为:
请使用空密码告知LDAP连接成功的原因 谢谢,
答案 0 :(得分:6)
似乎连接已绑定,但在发送实际请求之前未经过身份验证。
考虑以下内容,在绑定连接后发送请求......
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));**
}