How to get other properties from an LDAP principal (user) after login using Glassfish's LDAPRealm?

582 Views Asked by At

How can I get properties from a user after he successfully logged into my app, which is running on a Glassfish configured with a LDAP Realm?

Here's my scenario:

  • I have a LDAPRealm configured in my Glassfish which works fine.
  • I use form-based authentication. The form is a JSF page that works fine too.
  • I have a LoginBean which logins the user like this:

    HttpServletRequest req = (HttpServletRequest) FacesContext
    .getCurrentInstance()
    .getExternalContext()
    .getRequest();
    req.login(this.user, this.password);
    Principal p = req.getUserPrincipal();
    

My question is: how can I get, say, the email, givenName (or any other property my LDAP offers) of this Principal?

(I've done lots of googling but still no luck)

Thanks in advance.

0

There are 0 best solutions below