尝试使用LdapDirectoryIdentifier通过ldap进行身份验证,以便与openldap服务器进行通信。
代码段
dapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("ldap.com", 636);
LdapConnection lconn = new LdapConnection(ldi);
lconn.SessionOptions.ProtocolVersion = 3;
lconn.Bind();
lconn.Dispose();
运行代码在Bind()中给出了一个例外,说明LDAP服务器不可用。但在审查我的netstat后,连接就在那里并建立起来了。没有其他可用的错误消息。
有什么想法吗?
答案 0 :(得分:1)
端口636用于SSL。直接尝试使用LdapConnection以确保您可以通过SSL访问该服务器(SecureSocketLayer = true):
using (var ldapConnection = new LdapConnection("my.ad.server:636")) {
var networkCredential = new NetworkCredential(username, password, "my.ad.server");
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.AuthType = AuthType.Negotiate;
ldapConnection.Bind(networkCredential);
}
看看这是否有效。