1
我在Yii2工作與Adldap擴展在這裏找到:https://github.com/Adldap2/Adldap2Adldap2認證總是返回true - Yii2
我遇到一個問題,當我嘗試我的LDAP服務器上的用戶進行身份驗證。我可以成功建立連接並檢索用戶數據,但在嘗試驗證用戶的用戶名和密碼是否正確時,即使信用卡錯誤,它也會始終返回true。下面是我的代碼段(與配置陣列沒有顯示的路線):
$ad->addProvider($config);
try {
// If a successful connection is made to your server, the provider will be returned.
$provider = $ad->connect();
//User below does return the correct information from the ldap server
$user = $provider->search()->users()->find('quillin');
try{
$provider->auth()->attempt("wrongUsername","wrongPassword");
die("WIN");
}catch(Exception $e){
die("Exception " . $e);
}
}catch (\Adldap\Auth\BindException $e) {
die("There was an issue binding/connecting to the server. <br />" . $e);
}
不管是什麼,我把用戶名和密碼字段,它總是返回true,打模(「WIN」);線。在我composer.json文件,我使用「adldap2/adldap2」:「V7.0 *」
我也曾嘗試使用用戶綁定如下:
try{
$provider->auth()->attempt("wrongUsername","wrongPassword", $bindAsUser = true);
die("WIN");
}catch(Exception $e){
die("lose :(");
die("Exception " . $e);
}
這也總是返回true;