• Post Reply Bookmark Topic Watch Topic
  • New Topic

Logged in user information from LDAP  RSS feed

 
Tomas Linhart
Ranch Hand
Posts: 86
2
Java Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an application running on Tomcat that uses basic authentication for login. In Tomcat server.xml, I have JNDI realm defined. After the login, I want to retrieve some information about the logged in user from the LDAP server (Active Directory). (I use request.getRemoteUser() to get the logged in user.) That's going to happen in the servlet filter and I'll store the information in a form of Java Bean in the session. In the filter class, I can create the LdapContext, provide it the binding parameters and do the search and get the information. But I wonder if there is a way not to duplicate the connection parameters and reuse the JNDI realm definition in the Tomcat configuration instead.

Thanks.
Tomas
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Realms are plug-replaceable. If I want, I can use a MemoryRealm for development and an LDAP Realm for production and the only thing that would need to be changed is the server's configuration. Which is one of the reasons why the Realm's internals are strictly isolated from the application itself.

So, no, there's really no direct way to recycle that information. You could pass it as a context resource definition, but the app cannot query the Realm for internal information.
 
Tomas Linhart
Ranch Hand
Posts: 86
2
Java Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, that's basically what I thought after spending a couple of hours searching the Google. I just wanted to know if I didn't miss something.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!