mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
parent
96f5f8fd49
commit
86c63ec913
@ -7,13 +7,13 @@ use DateTime;
|
|||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Exception\AuthenticationException;
|
use Icinga\Exception\AuthenticationException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Repository\Repository;
|
use Icinga\Repository\LdapRepository;
|
||||||
use Icinga\Repository\RepositoryQuery;
|
use Icinga\Repository\RepositoryQuery;
|
||||||
use Icinga\Protocol\Ldap\Exception as LdapException;
|
use Icinga\Protocol\Ldap\Exception as LdapException;
|
||||||
use Icinga\Protocol\Ldap\Expression;
|
use Icinga\Protocol\Ldap\Expression;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
|
||||||
class LdapUserBackend extends Repository implements UserBackendInterface
|
class LdapUserBackend extends LdapRepository implements UserBackendInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The base DN to use for a query
|
* The base DN to use for a query
|
||||||
@ -64,18 +64,6 @@ class LdapUserBackend extends Repository implements UserBackendInterface
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Normed attribute names based on known LDAP environments
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $normedAttributes = array(
|
|
||||||
'uid' => 'uid',
|
|
||||||
'user' => 'user',
|
|
||||||
'inetorgperson' => 'inetOrgPerson',
|
|
||||||
'samaccountname' => 'sAMAccountName'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the base DN to use for a query
|
* Set the base DN to use for a query
|
||||||
*
|
*
|
||||||
@ -176,23 +164,6 @@ class LdapUserBackend extends Repository implements UserBackendInterface
|
|||||||
return $this->filter;
|
return $this->filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the given attribute name normed to known LDAP enviroments, if possible
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function getNormedAttribute($name)
|
|
||||||
{
|
|
||||||
$loweredName = strtolower($name);
|
|
||||||
if (array_key_exists($loweredName, $this->normedAttributes)) {
|
|
||||||
return $this->normedAttributes[$loweredName];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the given configuration to this backend
|
* Apply the given configuration to this backend
|
||||||
*
|
*
|
||||||
|
65
library/Icinga/Repository/LdapRepository.php
Normal file
65
library/Icinga/Repository/LdapRepository.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Repository;
|
||||||
|
|
||||||
|
use Icinga\Protocol\Ldap\Connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for concrete LDAP repository implementations
|
||||||
|
*
|
||||||
|
* Additionally provided features:
|
||||||
|
* <ul>
|
||||||
|
* <li>Attribute name normalization</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
abstract class LdapRepository extends Repository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The datasource being used
|
||||||
|
*
|
||||||
|
* @var Connection
|
||||||
|
*/
|
||||||
|
protected $ds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normed attribute names based on known LDAP environments
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $normedAttributes = array(
|
||||||
|
'uid' => 'uid',
|
||||||
|
'user' => 'user',
|
||||||
|
'group' => 'group',
|
||||||
|
'member' => 'member',
|
||||||
|
'inetorgperson' => 'inetOrgPerson',
|
||||||
|
'samaccountname' => 'sAMAccountName'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new LDAP repository object
|
||||||
|
*
|
||||||
|
* @param Connection $ds The data source to use
|
||||||
|
*/
|
||||||
|
public function __construct(Connection $ds)
|
||||||
|
{
|
||||||
|
parent::__construct($ds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the given attribute name normed to known LDAP enviroments, if possible
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getNormedAttribute($name)
|
||||||
|
{
|
||||||
|
$loweredName = strtolower($name);
|
||||||
|
if (array_key_exists($loweredName, $this->normedAttributes)) {
|
||||||
|
return $this->normedAttributes[$loweredName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user