2011-09-16 197 views
1

我正在使用以下代码使用SSL连接到LDAP服务器。以下代码将只在我关闭SSL标志时才起作用。任何人都可以告诉我我在这里缺少什么来进行SSL连接。我需要提供任何NetworkCredentials通过SSL连接时LDAP连接失败

每次的findAll把它叫做是说,

的服务器不可操作

ldapUrl="LDAP://x500.bund.de:389/l=Neutral,ou=BMI,o=Bund,c=DE"; 

DirectoryEntry dEntry =null; 

// for anonymous login. x500.bund.de supports this. 
dEntry = new DirectoryEntry(ldapUrl, null, null, 
      AuthenticationTypes.SecureSocketsLayer | AuthenticationTypes.Secure); 

DirectorySearcher search = new DirectorySearcher(dEntry); 

search.Filter = "((objectClass=*))";  
search.Filter = searchQuery; 
SearchResultCollection scl = search.FindAll(); 
+0

[C#:How to connect to Active Directory with SSL enabled?](http://stackoverflow.com/questions/1228998/c-how-to-connect-to-active-directory-with-ssl - 启用) –

+0

看到其他SO问题 - 我相信你需要使用端口636(而不是389)SSL连接... –

回答

3

389是LDAP明文端口。除非您使用STARTTLS指令并且服务器配置为支持它,否则不能使用SSL。按照marc_s的建议尝试636。