LdapUserGroupBackend: Fix method getMemberships()

refs #9950
This commit is contained in:
Johannes Meyer 2015-09-28 10:57:17 +02:00
parent d7655972ed
commit e7e3520375
1 changed files with 6 additions and 9 deletions

View File

@ -451,9 +451,9 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt
*/ */
public function getMemberships(User $user) public function getMemberships(User $user)
{ {
$queryUsername = $user->getUsername(); if ($this->isAmbiguous($this->groupClass, $this->groupMemberAttribute)) {
$queryValue = $user->getUsername();
if (($userDn = $user->getAdditional('ldap_dn')) === null) { } elseif (($queryValue = $user->getAdditional('ldap_dn')) === null) {
$userQuery = $this->ds $userQuery = $this->ds
->select() ->select()
->from($this->userClass) ->from($this->userClass)
@ -464,19 +464,16 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt
$userQuery->where(new Expression($this->userFilter)); $userQuery->where(new Expression($this->userFilter));
} }
if ($this->groupClass != 'posixGroup') { if (($queryValue = $userQuery->fetchDn()) === null) {
if (($queryUsername = $userQuery->fetchDn()) === null) {
return array(); return array();
} }
} }
}
$groupQuery = $this->ds $groupQuery = $this->ds
->select() ->select()
->from($this->groupClass, array($this->groupNameAttribute)) ->from($this->groupClass, array($this->groupNameAttribute))
->where($this->groupMemberAttribute, $queryUsername) ->where($this->groupMemberAttribute, $queryValue)
->setBase($this->groupBaseDn); ->setBase($this->groupBaseDn);
if ($this->groupFilter) { if ($this->groupFilter) {
$groupQuery->where(new Expression($this->groupFilter)); $groupQuery->where(new Expression($this->groupFilter));
} }