我正在开发一个用于重置 LDAP 用户密码的网站。我无法通过 ssl 与服务器建立连接。我尝试了各种代码和身份验证类型。
这是在服务器上用于与托管网站的 LDAP 连接的内容。我还使用两个 ssl 端口对其进行了测试。 636 和 3269。
0 = ldap_set_option(ld, LDAP_OPT_ENCRYPT, 1)
res = ldap_bind_s(ld, NULL, &NtAuthIdentity?, NEGOTIATE (1158)); v.3
{NtAuthIdentity?: User='_ldapuser'; Pwd='unavailable';; domain = 'SJTPNOC.DOMAIN'}
我在网站中使用以下代码
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("SJTP.DOMAIN",636));
connection.SessionOptions.ProtocolVersion = 3;
connection.AuthType = AuthType.Basic;
connection.Credential = new NetworkCredential("CN=user,CN=Users,DC=SJTPNOC,DC=DOMAIN", "password","CN=Users,DC=SJTPNOC,DC=DOMAIN");
connection.SessionOptions.SecureSocketLayer=true;
connection.Bind();
获取异常“LDAP 服务器不可用”。我用 389 端口尝试了该代码 没有 ssl,它工作正常。
请让我知道哪里出了问题。
最佳答案
如果你只想要加密而不需要 ldap 服务器的强认证,也许你应该添加:
connection.SessionOptions.VerifyServerCertificate =
new VerifyServerCertificateCallback((con, cer) => true);
关于c# - 连接以通过 ssl 打开 LDAP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12621256/