diff --git a/Manager/LdapManagerUser.php b/Manager/LdapManagerUser.php index 789a892..7807ddf 100644 --- a/Manager/LdapManagerUser.php +++ b/Manager/LdapManagerUser.php @@ -8,13 +8,14 @@ class LdapManagerUser implements LdapManagerUserInterface { private $ldapConnection, + $rolePrefix, $username, $password, $params, $ldapUser ; - public function __construct(LdapConnectionInterface $conn) + public function __construct(LdapConnectionInterface $conn, $rolePrefix) { $this->ldapConnection = $conn; $this->params = $this->ldapConnection->getParameters(); @@ -33,7 +34,7 @@ public function auth() if (strlen($this->password) === 0) { return false; } - + if (null === $this->ldapUser) { return ($this->bindByUsername() && $this->doPass()); } @@ -207,7 +208,7 @@ private function addLdapRoles() )); for ($i = 0; $i < $entries['count']; $i++) { - array_push($tab, sprintf('ROLE_%s', + array_push($tab, sprintf('ROLE_' . $this->rolePrefix . '%s', self::slugify($entries[$i][$this->params['role']['name_attribute']][0]) )); } diff --git a/Manager/LdapManagerUserInterface.php b/Manager/LdapManagerUserInterface.php index 0198cf6..a002f16 100644 --- a/Manager/LdapManagerUserInterface.php +++ b/Manager/LdapManagerUserInterface.php @@ -4,7 +4,7 @@ interface LdapManagerUserInterface { - function __construct(LdapConnectionInterface $conn); + function __construct(LdapConnectionInterface $conn, $rolePrefix); function exists($username); function auth(); function doPass(); diff --git a/Resources/config/security_ldap.xml b/Resources/config/security_ldap.xml index bf7cba1..a8cfd93 100644 --- a/Resources/config/security_ldap.xml +++ b/Resources/config/security_ldap.xml @@ -7,6 +7,7 @@ IMAG\LdapBundle\Provider\LdapUserProvider IMAG\LdapBundle\Manager\LdapConnection IMAG\LdapBundle\Manager\LdapManagerUser + IMAG\LdapBundle\Provider\LdapAuthenticationProvider IMAG\LdapBundle\EventListener\LdapListener Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint @@ -32,6 +33,7 @@ + %imag_ldap.ldap_manager.role_prefix%