Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OpenLDAP LDAP服务器不可用_C#_Asp.net_Solaris_Openldap_Su - Fatal编程技术网

C# OpenLDAP LDAP服务器不可用

C# OpenLDAP LDAP服务器不可用,c#,asp.net,solaris,openldap,su,C#,Asp.net,Solaris,Openldap,Su,在过去的四天里,我一直试图从asp.net连接到我们的OpenLDAP服务器,但没有成功。就在我发飙之前,有谁能想出一个行之有效的解决方案(即使用c#asp.net连接到OpenLDAP服务器)。显然,我可以从putty.exe访问ldap服务器并进行搜索。此外,我可以使用本地安装的Drupal CMS使用LDAP服务器进行身份验证,不会出现任何问题,因为我已经添加了LDAP模块。 我的问题是在asp.net中做同样的事情。具体内容如下: Ldap服务器托管在sun solaries上。 我的开

在过去的四天里,我一直试图从asp.net连接到我们的OpenLDAP服务器,但没有成功。就在我发飙之前,有谁能想出一个行之有效的解决方案(即使用c#asp.net连接到OpenLDAP服务器)。显然,我可以从putty.exe访问ldap服务器并进行搜索。此外,我可以使用本地安装的Drupal CMS使用LDAP服务器进行身份验证,不会出现任何问题,因为我已经添加了LDAP模块。 我的问题是在asp.net中做同样的事情。具体内容如下:

Ldap服务器托管在sun solaries上。 我的开发机器正在运行Win XP Service pack 3。 当我尝试使用我在putty中成功使用的用户名和密码调用bind时,会出现此错误

    string hostNameAndSSLPort = "ipaddress";
    string userName = "username";
    string password = "password";

    // establish a connection
    LdapConnection connection = new LdapConnection(hostNameAndSSLPort);

    // create an LdapSessionOptions object to configure session
    // settings on the connection.
    LdapSessionOptions options = connection.SessionOptions;

    options.ProtocolVersion = 3;


    options.SecureSocketLayer = true;

    connection.AuthType = AuthType.Basic;

    connection.Credential =
    new NetworkCredential(userName , password );

    try
    {
        connection.Bind();
    }
    catch(Exception e){
         lblSecurity.Text = e.Message;
    }
我甚至尝试使用 选项。StartTransportLayerSecurity(null);
在调用bind之前,相同的错误仍然存在。我可能做错了什么?请帮忙

有关一些有效的示例代码,请参见此答案

你提到使用XP。我相信有一个热修复程序可以修复XP上winldap的TLS实现中的一个问题。您必须在microsoft网站上搜索它。我记得它被埋在某个technet页面的某个地方

也不要将TLS与.net/winldap一起使用。你会不由自主地想知道为什么你的网站会随机地将cpu挂断,直到它被杀死。上面的答案有一个解释。只需使用SSL。

代码如下:

LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier(this._domain,     Convert.ToInt32(this._port)));
connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, cer) => true);
connection.SessionOptions.ProtocolVersion = 3;
connection.AuthType = AuthType.Basic;       
connection.SessionOptions.SecureSocketLayer = true;

我也有同样的问题。我的修正与上面的答案非常相似。问题是LDAP服务器正在发回证书,而客户端(我们的代码)不接受它。因此,通过添加以下代码,我庆祝并撕破了一件衬衫

connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, cer) => true);
或者用vb术语:

connection.SessionOptions.VerifyServerCertificate = New VerifyServerCertificateCallback(Function(con, cer) True)

您是否尝试过不使用SSL的方式,只是为了看看您是否可以通过这种方式连接?此外,在本文中:他们似乎使用了DN而不仅仅是用户名。。。也许在他们的示例中,bindDN等于username(uid?),但这可能是一个开始。我也遇到过一些问题,因为LDAP的配置方式(或某些古怪的防火墙规则…),我不得不简单地连接到SSL的非标准端口。LDAP服务器的证书是自签名的还是由证书颁发机构签名的?如果它是由认证机构签署的,它是公共的还是私人的?你可能有一系列的信任问题。另外,您遇到了什么特定的异常?还可以尝试指定ipAddress:portNumber。我尝试跟踪问题,我可以在autos窗口中看到问题立即开始,我调用新的LdapConnection(HostName和SSLPort)因为当我检查会话选项中的连接变量时,已出现错误+SecurityContext的connection.SessionOptions.SecurityContext“引发了类型为”System.DirectoryServices.Protocols.DirectoryOperationException“的异常对象{System.DirectoryServices.Protocols.DirectoryOperationException}在“安全上下文”和+SendTimeOut中感谢大家抽出时间来帮助我。我同样尝试过使用完整dn,但没有成功。正如我上面提到的,当我调用新连接时,问题就开始了。但是,我检查了主机是否可以从connection.options变量访问。