LdapUserGroupBackend: Fix exception when searching for single chars

refs #10370
This commit is contained in:
Johannes Meyer 2015-11-09 16:00:24 +01:00
parent 4341eef4b1
commit ffcc2ed56b

View File

@ -9,6 +9,7 @@ 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;
use Icinga\Protocol\Ldap\LdapException;
use Icinga\Repository\LdapRepository; use Icinga\Repository\LdapRepository;
use Icinga\Repository\RepositoryQuery; use Icinga\Repository\RepositoryQuery;
use Icinga\User; use Icinga\User;
@ -467,24 +468,28 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt
*/ */
protected function persistUserName($name) protected function persistUserName($name)
{ {
$userDn = $this->ds try {
->select() $userDn = $this->ds
->from($this->userClass, array()) ->select()
->where($this->userNameAttribute, $name) ->from($this->userClass, array())
->setUsePagedResults(false) ->where($this->userNameAttribute, $name)
->fetchDn(); ->setUsePagedResults(false)
if ($userDn) { ->fetchDn();
return $userDn; if ($userDn) {
} return $userDn;
}
$groupDn = $this->ds $groupDn = $this->ds
->select() ->select()
->from($this->groupClass, array()) ->from($this->groupClass, array())
->where($this->groupNameAttribute, $name) ->where($this->groupNameAttribute, $name)
->setUsePagedResults(false) ->setUsePagedResults(false)
->fetchDn(); ->fetchDn();
if ($groupDn) { if ($groupDn) {
return $groupDn; return $groupDn;
}
} catch (LdapException $_) {
// pass
} }
Logger::debug('Unable to persist uid or gid "%s" in repository "%s". No DN found.', $name, $this->getName()); Logger::debug('Unable to persist uid or gid "%s" in repository "%s". No DN found.', $name, $this->getName());