parent
60a8654614
commit
319ca3625c
|
@ -185,25 +185,6 @@ class LdapUserBackend extends UserBackend
|
|||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given user exists
|
||||
*
|
||||
* @param User $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasUser(User $user)
|
||||
{
|
||||
$username = $user->getUsername();
|
||||
$entry = $this->selectUser($username)->fetchOne();
|
||||
|
||||
if (is_array($entry)) {
|
||||
return in_array(strtolower($username), array_map('strtolower', $entry));
|
||||
}
|
||||
|
||||
return strtolower($entry) === strtolower($username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given user credentials are valid
|
||||
*
|
||||
|
@ -229,17 +210,16 @@ class LdapUserBackend extends UserBackend
|
|||
}
|
||||
}
|
||||
|
||||
if (! $this->hasUser($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$userDn = $this->conn->fetchDN($this->selectUser($user->getUsername()));
|
||||
if ($userDn === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$authenticated = $this->conn->testCredentials(
|
||||
$userDn,
|
||||
$password
|
||||
);
|
||||
|
||||
if ($authenticated) {
|
||||
$groups = $this->getGroups($userDn);
|
||||
if ($groups !== null) {
|
||||
|
|
|
@ -201,7 +201,7 @@ class Connection
|
|||
public function fetchDN(Query $query, $fields = array())
|
||||
{
|
||||
$rows = $this->fetchAll($query, $fields);
|
||||
if (count($rows) !== 1) {
|
||||
if (count($rows) > 1) {
|
||||
throw new LdapException(
|
||||
'Cannot fetch single DN for %s',
|
||||
$query->create()
|
||||
|
|
Loading…
Reference in New Issue