}
LdapConnection connection = LDAPConnectionUtil.openConnection(connectionParams);
try {
Cursor<SearchResponse> cursor = connection.search(USER_GROUP, searchQuery.toString(), SearchScope.ONELEVEL, "*");
while (cursor.next()) {
User user = new UserEntity();
SearchResultEntry response = (SearchResultEntry) cursor.get();
Iterator<EntryAttribute> itEntry = response.getEntry().iterator();
while(itEntry.hasNext()) {
EntryAttribute attribute = itEntry.next();
String key = attribute.getId();
if("uid".equalsIgnoreCase(key)) {
user.setId(attribute.getString());
} else if("sn".equalsIgnoreCase(key)) {
user.setLastName(attribute.getString());
} else if("cn".equalsIgnoreCase(key)) {
user.setFirstName(attribute.getString().substring(0, attribute.getString().indexOf(" ")));
}
}
userList.add(user);
}