This bundle provides LDAP authentication. It can also be used for authorization by retrieving the groups to which users belong and setting them as roles. It relies on the standard ldap php extension.
- it should be compliant with Symfony 3.4, 4.4 and 5.4
- ext-ldap
- symfony/ldap
composer require wiser/ldap-user-provider-bundle# config/services.yamlparameters:
ldap.host: 'dc.company.com'ldap.port: '389'ldap.user: 'user'# administrative account used to bind user/passwordldap.password: 'password'ldap.base_dn: 'dc=COMPANY,dc=ORG'ldap.roles_ou_filter: 'OU=APPLICATIONS,OU=GROUPS'services:
Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
arguments:
- host: '%ldap.host%'port: '%ldap.port%'Symfony\Component\Ldap\Ldap:
arguments: ['@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter']# config/packages/security.yamlsecurity:
providers:
my_ldap:
wiser_ldap: # this is the configuration key that matches this bundleservice: Symfony\Component\Ldap\Ldapbase_dn: '%ldap.base_dn%'search_dn: '%ldap.user%'search_password: '%ldap.password%'roles_ou_filter: '%ldap.roles_ou_filter%'# there are other configuration settings, check the code (LdapUserProviderFactory.php) to find them by yourself ;)firewalls:
restricted_area:
anonymous: trueform_login_ldap: ldaplogin_path: logincheck_path: logincsrf_token_generator: security.csrf.token_managerservice: Symfony\Component\Ldap\Ldapdn_string: '%ldap.base_dn%'search_dn: '%ldap.user%'search_password: '%ldap.password%'query_string: (&(ObjectClass=Person)(sAMAccountName={username}))provider: my_ldapNote:
You can refer to the official Symfony documentation : https://symfony.com/doc/current/security/ldap.html