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)
{
$queryUsername = $user->getUsername();
if (($userDn = $user->getAdditional('ldap_dn')) === null) {
if ($this->isAmbiguous($this->groupClass, $this->groupMemberAttribute)) {
$queryValue = $user->getUsername();
} elseif (($queryValue = $user->getAdditional('ldap_dn')) === null) {
$userQuery = $this->ds
->select()
->from($this->userClass)
@ -464,19 +464,16 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt
$userQuery->where(new Expression($this->userFilter));
}
if ($this->groupClass != 'posixGroup') {
if (($queryUsername = $userQuery->fetchDn()) === null) {
return array();
}
if (($queryValue = $userQuery->fetchDn()) === null) {
return array();
}
}
$groupQuery = $this->ds
->select()
->from($this->groupClass, array($this->groupNameAttribute))
->where($this->groupMemberAttribute, $queryUsername)
->where($this->groupMemberAttribute, $queryValue)
->setBase($this->groupBaseDn);
if ($this->groupFilter) {
$groupQuery->where(new Expression($this->groupFilter));
}