LdapUserBackend: Drop redundant method hasUser

refs #8826
This commit is contained in:
Johannes Meyer 2015-04-21 13:15:40 +02:00
parent 60a8654614
commit 319ca3625c
2 changed files with 5 additions and 25 deletions

View File

@ -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) {

View File

@ -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()