forked from GNUsocial/gnu-social
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:
parent
b8cb3d2833
commit
3f696ff0ed
@ -224,6 +224,11 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
|
|||||||
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
|
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$err=$ldap->bind();
|
$err=$ldap->bind();
|
||||||
if (Net_LDAP2::isError($err)) {
|
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());
|
throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
|
||||||
}
|
}
|
||||||
if($config == null) $this->default_ldap=$ldap;
|
if($config == null) $this->default_ldap=$ldap;
|
||||||
|
@ -167,6 +167,11 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
|
|||||||
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
|
$ldap->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$err=$ldap->bind();
|
$err=$ldap->bind();
|
||||||
if (Net_LDAP2::isError($err)) {
|
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());
|
throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user