[英]PHP ldap_bind “exception”
This is my code and it is working corrently. 这是我的代码,并且正在正常工作。
$authenticated = ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);
The description of this function specifies that it returns bool. 此函数的说明指定它返回bool。 When the user types an incorrect combination of username and password I get an error from the server: 当用户输入错误的用户名和密码组合时,我从服务器收到错误消息:
Error 500. ldap_bind(): Unable to bind to server: Invalid credentials
This is truly a PHP Warning but it stops the execution of my app. 这确实是一个PHP警告,但它停止了我的应用程序的执行。 It even shows the stack trace page (I'm working with Yii PHP Framework). 它甚至显示了堆栈跟踪页面(我正在使用Yii PHP Framework)。
I tried capturing an exception putting the ldap_bind() call inside a try/catch block: 我尝试捕获将ldap_bind()调用放入try / catch块中的异常:
try {
$authenticated = ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
It doesn't catch any exception and I'm still getting the same error: 它没有捕获任何异常,并且我仍然遇到相同的错误:
Error 500 ldap_bind(): Unable to bind to server: Invalid credentials
Can someone help me with this? 有人可以帮我弄这个吗? It seems that my users miss types their login credentials too often ;-) 看来我的用户经常错过输入他们的登录凭据的方式;-)
只需在ldap_bind前面放置一个@符号,然后使用$ authenticated变量(如果他们正确地进行了验证)就可以向用户显示。
$authenticated = @ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.