简体   繁体   中英

FOSUserBundle and LDAP user before login - Symfony2

I have successfully set up the FOSUserBundle and the FR3D LDAP bundle to allow my company users to login to the web app with their own login.

From now, if someone logins, they will have the default role, which is ROLE_USER. However, I only want a specific role to be allowed (in this case it's ROLE_CONSULT, which I created).

What I am doing to allow users at this moment is:

  1. Ask the user to login to the web app

  2. They get the "You have no right to access this web page"

  3. They tell me he connected

  4. I change the user's role to "ROLE_CONSULT" with a form I created within the admin panel.

What I want to do is:

  1. I select the user from the LDAP list

  2. Change the user role (which is not on the database yet, but will be as soon as I change the role)

  3. The user logins successfully

I already developed the 1 and 2 points, but as the "salt" is empty on the database, it doesn't allow the user to connect as it must believe the password isn't correct.

Any idea how I can make it work by telling Symfony2 it is the first login, it will automatically ONLY check the entered password at my LDAP configuration ?

Thanks.

Alright, that was easy.

I just forgot to put the "DN" to the database. Now it's working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM