To setup the LdapBundle, follow these steps:
Add
`"daps/ldap-bundle": "*@dev"`
to your`composer.json`
Add
`new Daps\LdapBundle\DapsLdapBundle()`
to the`app/AppKernel.php`
- Add the ldap config to
app/config/parameters.yml
parameters: daps_ldap.ldap.admin.dn: cn=admin,cn=Users,dc=example,dc=com daps_ldap.ldap.admin.password: admin daps_ldap.ldap.admin.enable: true daps_ldap.ldap.srv: False # or example.com to use srv records daps_ldap.ldap.host: ldap://example.com daps_ldap.ldap.port: 389 daps_ldap.ldap.dn: CN daps_ldap.ldap.username_suffix: cn=Users,dc=example,dc=com
- Add the ldap config to
- Modify
app/config/security.yml
and add your ldap user provider security: providers: daps_ldap: id: daps_ldap_user_provider
also tell Symfony how to encode passwords. For example
security: encoders: Daps\LdapBundle\Security\User\LdapUser: plaintext
You can now also ensure that you define the parts of your app that will be under LDAP protection. e.g
secured_area: pattern: ^/ form-login-ldap: true
- Modify
- Next, in your
apps/config/config.yml
file, import the service imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: "@DapsLdapBundle/Resources/config/services.yml"}
- Next, in your
Setup your
SecurityController
, routes and templates as detailed in the Security Chapter of the Symfony Documentation.