繁体   English   中英

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 服务器不可用。 但是在查看 my.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);
                }

看看这是否有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM