Sey*_*our 5 .net c# authentication service ldap
我们使用类似于以下的代码来建立到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();
}
Run Code Online (Sandbox Code Playgroud)
在测试期间,我们注意到以下预期行为:
不幸的是,我们还注意到以下意外行为:
请使用空密码告知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();
**con.SendRequest(new SearchRequest(targetLocation, "(objectClass=*)", System.DirectoryServices.Protocols.SearchScope.Subtree, null));**
}
Run Code Online (Sandbox Code Playgroud)