LdapUserGroupBackend: Add method persistUserName()

refs #10367
refs #10370
This commit is contained in:
Johannes Meyer 2015-10-16 15:28:44 +02:00
parent 58fc87b2e5
commit 8ed489c637
1 changed files with 37 additions and 0 deletions

View File

@ -5,6 +5,7 @@ namespace Icinga\Authentication\UserGroup;
use Icinga\Authentication\User\UserBackend; use Icinga\Authentication\User\UserBackend;
use Icinga\Authentication\User\LdapUserBackend; use Icinga\Authentication\User\LdapUserBackend;
use Icinga\Application\Logger;
use Icinga\Data\ConfigObject; use Icinga\Data\ConfigObject;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
@ -454,12 +455,48 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt
) )
); );
if (! $this->isAmbiguous($this->groupClass, $this->groupMemberAttribute)) { if (! $this->isAmbiguous($this->groupClass, $this->groupMemberAttribute)) {
$rules['group_membership']['user_name'] = 'user_name';
$rules['group_membership']['user'] = 'user_name';
$rules['group']['user_name'] = 'user_name'; $rules['group']['user_name'] = 'user_name';
$rules['group']['user'] = 'user_name';
} }
return $rules; return $rules;
} }
/**
* Return the distinguished name for the given uid or gid
*
* @param string $name
*
* @return string
*/
protected function persistUserName($name)
{
$userDn = $this->ds
->select()
->from($this->userClass, array())
->where($this->userNameAttribute, $name)
->setUsePagedResults(false)
->fetchDn();
if ($userDn) {
return $userDn;
}
$groupDn = $this->ds
->select()
->from($this->groupClass, array())
->where($this->groupNameAttribute, $name)
->setUsePagedResults(false)
->fetchDn();
if ($groupDn) {
return $groupDn;
}
Logger::debug('Unable to persist uid or gid "%s" in repository "%s". No DN found.', $name, $this->getName());
return $name;
}
/** /**
* Return the uid for the given distinguished name * Return the uid for the given distinguished name
* *