Found the answer thanks to 
http://www.deepakgaikwad.net/index.php/2009/09/24/retrieve-basic-user-attributes-from-active-directory-using-ldap-in-java.html

Here is an example

LdapContext ctx = ldapContextFactory.getSystemLdapContext();

final SearchControls constraints = new SearchControls();
                   
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
                    final String[] attrIDs = {"displayName", "mail"};
                    constraints.setReturningAttributes(attrIDs);

                    final NamingEnumeration<SearchResult> answer =
ctx.search("CN=Users,DC=foo,DC=bar", "sAMAccountName="
                            + token.getPrincipal().toString(), constraints);

                    if (answer.hasMore()) {
                        final Attributes attrs =
answer.next().getAttributes();
                        System.out.println(attrs.get("mail").get());
                        System.out.println(attrs.get("displayName").get());
                    } else {
                        throw new Exception("Invalid User");
                    }



--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/Retrieve-attributes-from-LDAP-active-directory-tp7577728p7577729.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to