c# - 连接以通过 ssl 打开 LDAP

标签 c# openldap

我正在开发一个用于重置 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/

相关文章:

c# - ods_Selected 行计数

c# - 如何在 ASP.NET MVC 3 项目的服务层生成 URL

c# - 无法将 IEnumerable 类型转换为 IEnumerable

java - LDAP 错误 : invalid structural object class chain (organizationalUnit/referral)

django - 如何使用 django-auth-ldap 实现身份验证?

linux - shared/home 和 OpenLDAP 的 SSH key 身份验证失败

c# - 安全异常 : Request for the permission of type 'System.Net.Mail.SmtpPermission'

c# - 格式化从其他网站随机复制的文本的最佳方式?

java - 尝试通过LSC(Ldap同步连接器)使Active Directory与openLDAP同步

linux - 当 Openldap 服务器上的 slapd 守护进程停止时,Openldap 客户端计算机挂起