Ldap\Connection: Do not suppress errors for failed credential tests

This commit is contained in:
Johannes Meyer 2015-06-23 14:12:01 +02:00
parent 5fd2eb639a
commit 197861efda

View File

@ -32,6 +32,7 @@ class Connection implements Selectable
const LDAP_NO_SUCH_OBJECT = 32; const LDAP_NO_SUCH_OBJECT = 32;
const LDAP_SIZELIMIT_EXCEEDED = 4; const LDAP_SIZELIMIT_EXCEEDED = 4;
const LDAP_ADMINLIMIT_EXCEEDED = 11; const LDAP_ADMINLIMIT_EXCEEDED = 11;
const LDAP_INVALID_CREDENTIALS = 49;
const PAGE_SIZE = 1000; const PAGE_SIZE = 1000;
/** /**
@ -557,23 +558,22 @@ class Connection implements Selectable
{ {
$this->connect(); $this->connect();
$r = @ldap_bind($this->ds, $username, $password); $success = @ldap_bind($this->ds, $username, $password);
if ($r) { if (! $success) {
Logger::debug( if (ldap_errno($this->ds) === self::LDAP_INVALID_CREDENTIALS) {
'Successfully tested LDAP credentials (%s / %s)', Logger::debug(
$username, 'Testing LDAP credentials (%s / %s) failed: %s',
'***' $username,
); '***',
return true; ldap_error($this->ds)
} else { );
Logger::debug( return false;
'Testing LDAP credentials (%s / %s) failed: %s', }
$username,
'***', throw new LdapException(ldap_error($this->ds));
ldap_error($this->ds)
);
return false;
} }
return true;
} }
/** /**