我试图连接到需要StartTLS但没有运气的LDAP服务器 - 每当我使用SessionOptions.StartTransportLayerSecurity(..)或将SessionOptions.SecureSocketLayer设置为true时,我得到例外。从System.DirectoryServices使用StartTLS与LDAP
下面是我使用的代码:
using (var connection = new LdapConnection(new LdapDirectoryIdentifier(config.LdapServer, config.Port, false, false)))
{
connection.SessionOptions.ProtocolVersion = 3;
connection.Credential = new NetworkCredential(config.BindDN, config.BindPassword);
connection.SessionOptions.VerifyServerCertificate += (conn, cert) => {return true;};
connection.AuthType = AuthType.Basic;
//connection.SessionOptions.SecureSocketLayer = true;
connection.SessionOptions.StartTransportLayerSecurity(null); // throws here, same if done after bind.
connection.Bind();
... do stuff with connection
}
产生的例外是“TlsOperationException:出现未知错误”,调用StartTransportLayerSecurity方法时发生。
我已经测试了针对OpenLDAP服务器和Active Directory的代码,但都不起作用。
有谁知道如何让StartTLS使用System.DirectoryServices?
可否请你指定的OpenLDAP针对特定版本,Active Directory和特别是操作系统*双向*客户端和服务器这里涉及到缩小范围有多大?过去有相当多的微妙的LDAP堆栈不兼容,这仍然适用于您的客户可能使用的潜在遗留场景。 – 2012-01-23 11:46:10
斯特芬嗨,信息是OpenLDAP的2.4.18,FreeBSD的服务器和客户端是在Windows Server 2008 R2的计算机(客户端代码中的ASP.Net应用程序托管,.Net框架3.5 SP1)。 在LDAP的版本上进一步搜索,让我有关于该主题的一些博客文章,包括: http://pongo15.wordpress.com/2009/12/18/on-getting-openldap-and-windows- ldap-to-interop/- 帮助我深入了解问题的底部。 我要去尝试,并鼓励用户向上移动到最新的OpenLDAP,因为我认为这个问题可能是固定在以后的版本(他们的版本是真的老了,太阳公布,2009年6月) – Bittercoder 2012-01-26 10:26:16
感谢跟进信息,这将有助于后来的读者对这样的问题(+1)!我[更新我的答案](http://stackoverflow.com/posts/9020311/revisions#)相应... – 2012-01-26 15:40:50