Skip to content

Commit

Permalink
LdapUserGroupBackend: Allow to link a user backend
Browse files Browse the repository at this point in the history
refs #7343
  • Loading branch information
Johannes Meyer committed Jun 5, 2015
1 parent 127489c commit 0ab192c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php
Expand Up @@ -3,7 +3,10 @@

namespace Icinga\Authentication\UserGroup;

use Icinga\Authentication\User\UserBackend;
use Icinga\Authentication\User\LdapUserBackend;
use Icinga\Data\ConfigObject;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\ProgrammingError;
use Icinga\Protocol\Ldap\Expression;
use Icinga\Repository\LdapRepository;
Expand Down Expand Up @@ -540,6 +543,8 @@ public function getMemberships(User $user)
* @param ConfigObject $config
*
* @return $this
*
* @throws ConfigurationError In case a linked user backend does not exist or is not a LdapUserBackend
*/
public function setConfig(ConfigObject $config)
{
Expand All @@ -551,6 +556,20 @@ public function setConfig(ConfigObject $config)
$defaults = new ConfigObject();
}

if ($config->user_backend) {
$userBackend = UserBackend::create($config->user_backend);
if (! $userBackend instanceof LdapUserBackend) {
throw new ConfigurationError('User backend "%s" is not of type LDAP', $config->user_backend);
}

$defaults->merge(array(
'user_base_dn' => $userBackend->getBaseDn(),
'user_class' => $userBackend->getUserClass(),
'user_name_attribute' => $userBackend->getUserNameAttribute(),
'user_filter' => $userBackend->getFilter()
));
}

return $this
->setGroupBaseDn($config->base_dn)
->setUserBaseDn($config->get('user_base_dn', $this->getGroupBaseDn()))
Expand Down

0 comments on commit 0ab192c

Please sign in to comment.