Change ROLE with LDAP & Symfony

105 views Asked by At

In this projet, im login trough Active Directory. the default role is : ROLE_USER.

security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
    Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
    ldap:
        ldap:
            service: Symfony\Component\Ldap\Ldap
            base_dn: 'DC=DOMAIN,DC=COM'
            search_dn: '%env(LDAP_ADMIN_ACCOUNT)%'            
            search_password: '%env(LDAP_PASSWORD)%'
            default_roles: ROLE_USER
            uid_key: sAMAccountName
            # filter: (&(objectclass=user)(sAMAccountName={user_identifier}))

In my controller, i can retrieve my account's attributes. And i want to change my users's role according to the memberOf attribute.

It's possible ? I dont have any entity in this project.

Since my first post, i couldn't change the role. So, i change few sessions attributes for access management.

0

There are 0 answers