我的登录窗口使用LDAP对用户进行身份验证。但是,在验证时,它总是返回false。wpf - 验证时LDAP始终返回false
下面是验证代码,我从CodeProject上了:
public bool fnValidateUser()
{
bool validation;
try
{
LdapConnection lcon = new LdapConnection
(new LdapDirectoryIdentifier((string)null, false, false));
NetworkCredential nc = new NetworkCredential(Environment.UserName,
txtPassword.SecurePassword, Environment.UserDomainName);
lcon.Credential = nc;
lcon.AuthType = AuthType.Negotiate;
// user has authenticated at this point,
// as the credentials were used to login to the dc.
lcon.Bind(nc);
validation = true;
}
catch (LdapException)
{
validation = false;
}
return validation;
}
txtPassword.SecurePassword
是PasswordBox。当我输入我的密码/ PIN并点击登录时,只要验证为false,它就会显示MessageBox。
我在做什么错?
UPDATE:的异常指示“的LDAP服务器不可用”,在这条线lcon.Bind(nc);
添加一个日志来捕捉异常,以及你作为异常得到了什么? – Dinesh
@Dinesh我刚刚添加了它 – bruh1234
根据此例外情况,您的LDAP服务器已关闭或根本没有连接。 – Dinesh