Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Manager/LdapManagerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -33,7 +34,7 @@ public function auth()
if (strlen($this->password) === 0) {
return false;
}

if (null === $this->ldapUser) {
return ($this->bindByUsername() && $this->doPass());
}
Expand Down Expand Up @@ -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])
));
}
Expand Down
2 changes: 1 addition & 1 deletion Manager/LdapManagerUserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

interface LdapManagerUserInterface
{
function __construct(LdapConnectionInterface $conn);
function __construct(LdapConnectionInterface $conn, $rolePrefix);
function exists($username);
function auth();
function doPass();
Expand Down
2 changes: 2 additions & 0 deletions Resources/config/security_ldap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<parameter key="imag_ldap.security.user.provider.class">IMAG\LdapBundle\Provider\LdapUserProvider</parameter>
<parameter key="imag_ldap.ldap_connection.class">IMAG\LdapBundle\Manager\LdapConnection</parameter>
<parameter key="imag_ldap.ldap_manager.class">IMAG\LdapBundle\Manager\LdapManagerUser</parameter>
<parameter key="imag_ldap.ldap_manager.role_prefix"></parameter>
<parameter key="imag_ldap.security.authentication.provider.class">IMAG\LdapBundle\Provider\LdapAuthenticationProvider</parameter>
<parameter key="imag_ldap.security.authentication.listener.class">IMAG\LdapBundle\EventListener\LdapListener</parameter>
<parameter key="imag_ldap.security.authentication.form_entry_point.class">Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint</parameter>
Expand All @@ -32,6 +33,7 @@

<service id="imag_ldap.ldap_manager" class="%imag_ldap.ldap_manager.class%">
<argument type="service" id="imag_ldap.ldap_connection" />
<argument>%imag_ldap.ldap_manager.role_prefix%</argument>
</service>

<service id="imag_ldap.security.authentication.provider" class="%imag_ldap.security.authentication.provider.class%">
Expand Down