我正在编写一个应用程序,通过adLdap库检查用户是否登录。
但问题是,当用户输入错误的密码时,在第4次之后,它会锁定他的帐户。对此我能做些什么吗?或者LDAP就是这样工作的?
这是我正在使用的代码:
public static function checkLogin ($username, $password) {
$ldap = new adLDAP();
if ($ldap->authenticate($username, $password)) {
return true;
}
return false;
}
锁定帐户的不是adLDAP也不是LDAP。您的网络管理员已经在Windows Active Directory中设置了几个规则,其中之一是在尝试了4次不正确的密码后锁定帐户。
这是一个只能在ADUC(Active Directory用户和计算机)中更改的安全功能。
我从未使用过LDAP,但我按如下方式解决了这个问题:
加载网站的索引时,将创建一个$_SESSION['count']来计算登录尝试的次数。如果在任何时候这个数字超过4次尝试,我会对数据库进行更新以锁定用户的密码。
参见示例:
public static function checkLogin ($username, $password) {
if($_SESSION['count'] >= 4 || $this->UserLocked()) {
return false; //User Locked | note that even created a method to check whether the user is locked or not.
} else {
$ldap = new adLDAP();
if ($ldap->authenticate($username, $password)) {
return true;
}
$_SESSION['count']++;
return false;
}
}