LdapConnection connection = LDAPConnectionUtil.openConnection(connectionParams);
try {
Cursor<SearchResponse> cursor = connection.search(GROUP_ENTRY, "(uniqueMember= uid=" + userId
+ "," + USER_ENTRY + ")", SearchScope.ONELEVEL, "*");
while (cursor.next()) {
Group group = new GroupEntity();
SearchResultEntry response = (SearchResultEntry) cursor.get();
Iterator<EntryAttribute> itEntry = response.getEntry().iterator();
while(itEntry.hasNext()) {
EntryAttribute attribute = itEntry.next();
String key = attribute.getId();
if("cn".equalsIgnoreCase(key)) {
group.setId(attribute.getString());
group.setName(attribute.getString());
}
}
groupList.add(group);
}