0

I would like to configure both LDAP and Mysql database for user and role management.

Recently I have integrated the users and role management with LDAP and Spring security, But the user and role management can also be fetched from the database.

For example, while creating a user account there will be one option to choose whether the user should be stored in LDAP or in database. If the user is stored in databse then it fetches from the database or else from LDAP.

But how can I configure the spring security to search for the user in database and LDAP?.

Please, Can anyone provide me with the spring configuration code snippet? I am new to spring security and LDAP. Thanks in advance.

Keval Bhatt
  • 152
  • 1
  • 12
  • I can give you the configuration idea and i can point to working code snippet but need clarification so that i suggest correctly. – PraveenKumar Lalasangi Oct 13 '19 at 07:26
  • Here in your case it is all about authentication, i want to know your exact requirement. Do you need to set up fall back authentication or selected authentication? – PraveenKumar Lalasangi Oct 13 '19 at 07:29
  • **Fallback authentication**: If credential supplied does not match with LDAP then verify in database. **Note that** different users present in different context(LDAP and Databse) may have same username. Then if you chose fallback authentication then there might be chances of getting invalid credentials message depending on order of fallback authentication configured. Worst case is if both users has same credentials. – PraveenKumar Lalasangi Oct 13 '19 at 07:35
  • **Selected authentication provider:** Here while logging in user will be given a radio button or dropdown to select he is a LDAP user or Database user. Based on input provided user will be authenticated with the corresponding authentication provider. If authentication fails it will not continue to the next authentication. **Update the question and notify me** – PraveenKumar Lalasangi Oct 13 '19 at 07:40
  • Hi, thanks for the comment. While creating user the admin will supposed to select that is user part of LDAP ? Or not. I would like to set the LDAP integration as an option not mandatory. Can you please provide me configuration idea. Thanks in advance – Keval Bhatt Oct 13 '19 at 08:38
  • Refer this [**thread**](https://stackoverflow.com/q/4783063/2825798), complete thread has very interesting content. Refer my answer for java config way of solution. – PraveenKumar Lalasangi Oct 13 '19 at 13:36
  • @KevalBhatt Are you able to solve your problem? – K.D Oct 17 '19 at 11:21

0 Answers0