LDAP Authentication with Symfony 2.8

前端 未结 4 1125
时光取名叫无心
时光取名叫无心 2021-02-09 08:20

I\'m trying to use the new LdapUserProvider in Symfony 2.8. I believe I have configured everything per the docs.

My user can successfully authenticate, and then gets red

4条回答
  •  滥情空心
    2021-02-09 08:55

    In Symfony 3.1, the LdapClient component was deprecated. So I wanted to update the solution. This solution should also work for Symfony 2.8/2.9 apps.

    #security.yml
    security:
        firewalls:
            restricted_area:
                provider: app_users
                form_login_ldap:
                    service: ldap.auth
                    dn_string: "%dn_string%"
    
        providers:
            app_users:
                ldap:
                    service: ldap.auth
                    base_dn: "dc=domain,dc=net"
                    search_dn: "cn=Manager,DC=domain,DC=net"
                    search_password: secretPassword
                    filter: "(&(aptAccountEnabled=1)(ObjectClass=aptAccount)({uid_key}={username}))"
                    default_roles: ROLE_USER
                    uid_key: uid
    
    #services.yml
    services:
        ldap.auth:
            class: 'Symfony\Component\Ldap\Ldap'
            factory:
                - 'Symfony\Component\Ldap\Ldap'
                - 'create'
            arguments:
                - 'ext_ldap'  # adapter
                -
                  host: database
                  options:
                      protocol_version: 3
    

提交回复
热议问题