C# ASP.NET 应用程序使用 ldap 进行身份验证
C# ASP.NET application using ldap for authentication
正在尝试使用 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 后,连接就在那里并建立了。没有其他可用的错误消息。
有什么想法吗?
端口 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);
}
看看这是否有效。
正在尝试使用 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 后,连接就在那里并建立了。没有其他可用的错误消息。
有什么想法吗?
端口 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);
}
看看这是否有效。