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,15 +558,9 @@ 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)',
$username,
'***'
);
return true;
} else {
Logger::debug( Logger::debug(
'Testing LDAP credentials (%s / %s) failed: %s', 'Testing LDAP credentials (%s / %s) failed: %s',
$username, $username,
@ -574,6 +569,11 @@ class Connection implements Selectable
); );
return false; return false;
} }
throw new LdapException(ldap_error($this->ds));
}
return true;
} }
/** /**