Login with FR3D LDAP Bundle and FOS User Bundle

2.6k Views Asked by At

First, sorry for my English: I'm French and I don't speak English very well.

I try to login my users in Intranet website on an LDAP directory. So I decided to use FR3D Ldap Bundle and FOS User Bundle on SF 2.0.X.

I have already installed FOSUB and it works fine with a Mysql DB. After, I install FR3D Ldap Bundle => OK.

Now I have a problem with configuration. When I try to log with a user in the FOSUB login form, I have a error message: "The presented password is invalid."

This is my security config :

 main:
        pattern: ^/                      # ^/ = tout ce qui commence par / = tout notre site
        #fr3d_ldap:  ~
        form_login: # On définit notre méthode d'authentification
            always_use_default_target_path: false
            default_target_path: /annu
            provider:    chain_provider  # On lit l'authentification au provider définit plus haut
            remember_me: true            # On active la possibilité du "Se souvenir de moi" (désactivé par défaut)
        remember_me:
            lifetime: 604800                # in seconds
            key:         %secret%        # On définit la clé pour le remember_me (%secret% est un parametre de parameters.ini)
        anonymous:       true            # On autorise les utilisateurs anonymes (non identifiés)
        logout:   
            path:   /logout
            target: /annu 




providers:
        chain_provider:
            providers: [fos_userbundle, fr3d_ldapbundle]
        in_memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
        fos_userbundle:
            id: fos_user.user_manager
        fr3d_ldapbundle:
            id: fr3d_ldap.security.user.provider

I don't understand why I can't log my users because I see LDAP request on Wireshark.

1

There are 1 best solutions below

0
On

You have commented the LDAP Authenticator "#fr3d_ldap: ~"

You must uncomment it for authentication. The LDAP request which you are seeing on Wireshark are the queries for provide the user.

Symfony requires two step for authenticate a user:

1) Retrieve the user from the repository (query to LDAP Directory) This step is doing by adding fr3d_ldap.security.user.provider to the providers: section

2) Authenticate it with his credentials (Bind to LDAP Directory) This step is doing by adding fr3d_ldap: ~ to the <firewall name:> section.

Removing the # character at the begin of fr3d_ldap: ~ should fix your issue.