I'm struggling with implementing Fr3d LDAP Bundle (with FOSUserbundle) into Symfony. I came that far as being able to login for the first time and getting registered in the database. Though now I got the problem that I can't login a second time. It just throws "bad username and password". Here are my configs:
config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: example\AcmeBundle\Entity\User
fr3d_ldap:
driver:
host: ldap.example.de
port: 389
useSsl: false;
user:
baseDn: ou=people, dc=example, dc=de
attributes:
- { ldap_attr: uid, user_method: setUsername }
- { ldap_attr: mail, user_method: setEmail }
filter: (objectClass=*)
Security.yml
security:
firewalls:
main:
pattern: ^/
fr3d_ldap: ~
form_login:
always_use_default_target_path: true
default_target_path: /profile
provider: chain_provider
logout: true
anonymous: true
providers:
chain_provider:
chain:
providers: [fos_userbundle, fr3d_ldapbundle]
fr3d_ldapbundle:
id: fr3d_ldap.security.user.provider
fos_userbundle:
id: fos_user.user_manager
encoders:
example\AcmeBundle\Entity\User : plaintext
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
I searched and tried everything I could find on the net, but since nearly all of the documentation is pretty old I couldn't find anything.
EDIT Actually a colleague of mine just found the answer.
For our LDAP to recognize the user you need to supply the bind with the uid via "uid=". We solved the problem now by giving the filter another argument which looks like this:
user:
baseDn: ou=people, dc=example, dc=de
attributes:
- { ldap_attr: uid, user_method: setUsername }
- { ldap_attr: mail, user_method: setEmail }
filter: (&(objectClass=Person)(uid=%s))
I'm sorry for the inconvenience!