1

我正在开发一个网站来管理 ldap。我陷入了一种情况,当我尝试对帐户锁定或禁用的用户进行身份验证时,它失败了。我想要做的是在显示帐户被锁定或禁用的消息之后首先对用户进行身份验证。

我正在这样编码

LdapConnection connection = new LdapConnection(new       LdapDirectoryIdentifier("SJTPNOC.com", 636));
connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, cer) => true);
connection.SessionOptions.ProtocolVersion = 3;        
connection.AuthType = AuthType.Basic;       
connection.SessionOptions.SecureSocketLayer = true;
connection.Timeout = new TimeSpan(0, 0, 10);   
connection.Credential = new NetworkCredential(username, password);
using (connection){
connection.Bind();
}
4

1 回答 1

2

不确定我是否理解这一点 - 如果用户被锁定或禁用,他们将无法进行身份验证。您应该捕获从 LDAP 返回的错误并使用该信息向用户显示友好的消息,或者查找用户并读取指示用户状态的属性(例如 AD 中的 userAccountControl)。

于 2012-12-18T19:37:17.117 回答