簡體   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