ldap_get_connection() to return null when passed a config with bad user/pw.

This mainly affects login; before if the user enters a valid username
but invalid password, ldap_get_connection() throws an
LDAP_INVALID_CREDENTIALS error. Now the user sees the regular
"Incorrect username of password" error message.
This commit is contained in:
Jeffery To 2010-03-05 17:54:53 +08:00 committed by Craig Andrews
parent b8cb3d2833
commit 3f696ff0ed
2 changed files with 10 additions and 0 deletions

View File

@ -224,6 +224,11 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
$err=$ldap->bind();
if (Net_LDAP2::isError($err)) {
// if we were called with a config, assume caller will handle
// incorrect username/password (LDAP_INVALID_CREDENTIALS)
if (isset($config) && $err->getCode() == 0x31) {
return null;
}
throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
}
if($config == null) $this->default_ldap=$ldap;

View File

@ -167,6 +167,11 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
$err=$ldap->bind();
if (Net_LDAP2::isError($err)) {
// if we were called with a config, assume caller will handle
// incorrect username/password (LDAP_INVALID_CREDENTIALS)
if (isset($config) && $err->getCode() == 0x31) {
return null;
}
throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
return false;
}