Module administration

Rebase fix ldap auth for testing issue.

refs #4092
This commit is contained in:
Marius Hein 2013-06-26 16:48:07 +02:00
parent d1f4e9831a
commit 72bb02d390
1 changed files with 13 additions and 3 deletions

View File

@ -8,6 +8,7 @@ use Icinga\Authentication\User as User;
use Icinga\Authentication\UserBackend; use Icinga\Authentication\UserBackend;
use Icinga\Authentication\Credentials; use Icinga\Authentication\Credentials;
use Icinga\Protocol\Ldap; use Icinga\Protocol\Ldap;
use Icinga\Application\Config;
class LdapUserBackend implements UserBackend class LdapUserBackend implements UserBackend
{ {
@ -33,8 +34,16 @@ class LdapUserBackend implements UserBackend
protected function selectUsername($username) protected function selectUsername($username)
{ {
return $this->connection->select() return $this->connection->select()
->from('user', array('sAMAccountName')) ->from(
->where('sAMAccountName', $this->stripAsterisks($username)); Config::getInstance()->authentication->users->user_class,
array(
Config::getInstance()->authentication->users->user_name_attribute
)
)
->where(
Config::getInstance()->authentication->users->user_name_attribute,
$this->stripAsterisks($username)
);
} }
public function authenticate(Credentials $credentials) public function authenticate(Credentials $credentials)
@ -42,7 +51,8 @@ class LdapUserBackend implements UserBackend
if (!$this->connection->testCredentials( if (!$this->connection->testCredentials(
$this->connection->fetchDN($this->selectUsername($credentials->getUsername())), $this->connection->fetchDN($this->selectUsername($credentials->getUsername())),
$credentials->getPassword() $credentials->getPassword()
) ) { )
) {
return false; return false;
} }
$user = new User($credentials->getUsername()); $user = new User($credentials->getUsername());