Does it possible anyhow to avoid php warning on the screen when are invalid credentials on ldap_bind, but without use @ldap_bind or error_reporting set to 0?
I tried with:
try {
if(!ldap_bind($ds, $binddn, $password)) {
throw new Exception('Invalid credentials');
}
} catch (Exception $e) {
var_dump($e->getMessage());
}
But it doesn't work. PHP warning is still on the screen.
Does anyone know solution?
Have a look at http://php.net/manual/de/errorfunc.configuration.php#ini.display-errors
It's nothing to do with the ldap-extension but with your php-settings. You should use the log_errors
-directive in php.ini to log errors to an error-log.
And as the ldap-extension currently doesn't throw exceptions you will not have much luck with wrapping the ldap_bind
into a try-catch
-Block. You can though add a custom error-handler right before the call to any of the ldap-functions and replace that one with the default-error-handler.
For that have a look at http://php.net/manual/de/function.set-error-handler.php and https://github.com/zendframework/zend-ldap/blob/master/src/Ldap.php#L825-L827
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.