通过SSL连接到LDAP [英] Connect to LDAP over ssl
问题描述
我在一个用于重置ldap用户密码的网站上工作.
我无法通过ssl与服务器建立连接.我尝试了各种代码和身份验证类型.
这是在服务器上用于与托管网站的ldap进行连接的方法.
我还使用ssl端口636和3269对其进行了测试.
Hi ,
I am working on a website which is used to reset password of ldap users.
I am not able to make connection with server over ssl. I tried various code and authentication types.
This is what used on server for connectivity with ldap on which website is hosted.
I also tested it with both ssl ports 636 and 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'}
我正在网站中使用以下代码
I am using following code in website
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的代码,并且可以正常工作.
请让我知道出了什么问题. 请帮我急.
Getting exception "LDAP server is unavailable". I tried that code with 389 port and without ssl and its working fine.
Please let me know what is wrong. Help me its urgent.
推荐答案
只需再添加一行
Just add one more line
connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, cer) => true);
这篇关于通过SSL连接到LDAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!