mercredi 8 février 2017

Spring LDAP template usage for user authentication per request

Vote count: 0

I have a catch 22. I am implementing a service client whose responsibility is to authenticate a user at an LDAP server. The client accepts a userid and password, determines the userDn, and invoke a request to the LDAP server. My problem is the way spring ldap template is setup at the moment. The ldaptemplate requires a contextsource at bean creationtime. The contextsource is configured at creation time to some value (ldapurl, userdn, password). But I realized that my contextsource will change with each user. Each user opens a connection based on the user's DN. So, my contextsource is different per user and therefor creating a contextsource at beancreation time(container startup) is not the right place. And, there is no way of overriding the contextsource (with the userid/password) through the ldaptemplate AFAIK. So, is it a good idea to create an LdapcontextSource object explicitly in my code by initializing it explicitly with the actual userid and password (and the url of which is a constant over all users) and update my ldaptemplate bean by using the setter method of ldaptemplate? After my client call I will dispose the contextsource by setting it to null (the template outlives the operation because it is a bean living in the spring container. So it could be reused and therefor the previous information on the context must not be available.) Question: Is there another solution to this problem as described above?

asked 23 secs ago

Let's block ads! (Why?)



Spring LDAP template usage for user authentication per request

Aucun commentaire:

Enregistrer un commentaire