Reputation: 5721
I would like to collect various information from an active directory using Java. I've reviewed this post How to connect with Java into Active Directory
I'm able to connect to the active directory and get the user's display name, but I would like to get the user's account name (login username) and email (if one is configured).
Please advise if and how I can get this information. Thanks in advance.
Upvotes: 1
Views: 1551
Reputation: 1706
It's easy to retrieve info using the required information key (name) like below to get the email .
while (answer.hasMoreElements())
{
SearchResult sr = (SearchResult)answer.next();
System.out.println("user name" + sr.getName());
Attributes attrs = sr.getAttributes();
System.out.println("email" + attrs.get("mail"));
}
EDIT : check here the attributes list in ldap
Upvotes: 2