}
NamingEnumeration<SearchResult> answer = dir.search(baseDn, filter, ctls);
while (answer.hasMore()) {
SearchResult st = (SearchResult) answer.next();
LDAPUser usr = new LDAPUser();
Attributes atts = st.getAttributes();
Attribute mailAtt = atts.get(mailAttrName);
if (mailAtt != null) {
usr.setMail((String) mailAtt.get());
}
Attribute cnAtt = atts.get(cnAttrName);
if (cnAtt != null) {
usr.setDisplayName((String) cnAtt.get());
}
Attribute uidAtt = atts.get(uidAttrName);
if (uidAtt != null) {
usr.setUid((String) uidAtt.get());
}
Attribute ptitleAtt = atts.get(personalTitleAttrName);
if (ptitleAtt != null) {
usr.setTitle((String) ptitleAtt.get());
}
Attribute genderAtt = atts.get(genderAttrName);
if (genderAtt != null) {
usr.setGender((String) genderAtt.get());
}
Attribute surNameAtt = atts.get(snAttrName);
if (surNameAtt != null) {
usr.setLastName((String) surNameAtt.get());
}
Attribute firstNameAtt = atts.get(givennameAttrName);
if (firstNameAtt != null) {
usr.setFirstName((String) firstNameAtt.get());
}
return usr;
}
} catch (NamingException nex) {