if (results.hasMoreElements()) {
logger.info("has returned results..\n");
user = new JSONObject();
// Since UID is unique across the entire directory,
// the search results should contain only one entry.
SearchResult sr = (SearchResult) results.next();
// we need the DN to authenticate the user
NameParser parser = ctx.getNameParser(BASE);
Name userDN = parser.parse(BASE);
if (userDN == (Name) null)
// This should not happen in theory
throw new NameNotFoundException();
else
userDN.addAll(parser.parse(sr.getName()));
user.put("userDN", userDN.toString());
// Get all available attribute types and their associated values.
// we can build a user object to return.
Attributes attributes = sr.getAttributes();
Attribute attr;
NamingEnumeration<?> ne;
// Iterate through the attributes.