mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Merge branch 'bugfix/ldap-group-to-roles-assignment-not-working-9950'
fixes #9950
This commit is contained in:
commit
30fa554ad9
@ -12,6 +12,7 @@ use Icinga\Protocol\Ldap\Expression;
|
|||||||
use Icinga\Repository\LdapRepository;
|
use Icinga\Repository\LdapRepository;
|
||||||
use Icinga\Repository\RepositoryQuery;
|
use Icinga\Repository\RepositoryQuery;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
use Icinga\Application\Logger;
|
||||||
|
|
||||||
class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBackendInterface
|
class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBackendInterface
|
||||||
{
|
{
|
||||||
@ -532,6 +533,11 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken
|
|||||||
*/
|
*/
|
||||||
public function getMemberships(User $user)
|
public function getMemberships(User $user)
|
||||||
{
|
{
|
||||||
|
if ($this->groupClass === 'posixGroup') {
|
||||||
|
# Posix group only uses simple user name
|
||||||
|
$userDn = $user->getUsername();
|
||||||
|
} else {
|
||||||
|
# LDAP groups use the complete DN
|
||||||
if (($userDn = $user->getAdditional('ldap_dn')) === null) {
|
if (($userDn = $user->getAdditional('ldap_dn')) === null) {
|
||||||
$userQuery = $this->ds
|
$userQuery = $this->ds
|
||||||
->select()
|
->select()
|
||||||
@ -547,6 +553,7 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$groupQuery = $this->ds
|
$groupQuery = $this->ds
|
||||||
->select()
|
->select()
|
||||||
@ -557,10 +564,12 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken
|
|||||||
$groupQuery->where(new Expression($this->groupFilter));
|
$groupQuery->where(new Expression($this->groupFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::debug('Fetching groups for user %s using filter %s.', $user->getUsername(), $groupQuery->__toString());
|
||||||
$groups = array();
|
$groups = array();
|
||||||
foreach ($groupQuery as $row) {
|
foreach ($groupQuery as $row) {
|
||||||
$groups[] = $row->{$this->groupNameAttribute};
|
$groups[] = $row->{$this->groupNameAttribute};
|
||||||
}
|
}
|
||||||
|
Logger::debug('Fetched %d groups: %s.', count($groups), join(', ', $groups));
|
||||||
|
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user