+ try {
+ String searchFilter = filter;
+ SearchControls searchControls = new SearchControls();
+ searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ String searchBase = baseDn;
+ NamingEnumeration<SearchResult> results = initialLdapContext
+ .search(searchBase, searchFilter, searchControls);
+
+ ArrayList<Role> res = new ArrayList<Role>();
+ while (results.hasMoreElements()) {
+ SearchResult searchResult = results.next();
+ Attributes attrs = searchResult.getAttributes();
+ String name = searchResult.getName();
+ LdifUser role;
+ if (attrs.get("objectClass").contains("groupOfNames"))
+ role = new LdifGroup(new LdapName(name), attrs);
+ else if (attrs.get("objectClass").contains("inetOrgPerson"))
+ role = new LdifUser(new LdapName(name), attrs);
+ else
+ throw new ArgeoUserAdminException(
+ "Unsupported LDAP type for " + name);
+ res.add(role);
+ }
+ return res.toArray(new Role[res.size()]);
+ } catch (Exception e) {
+ throw new ArgeoUserAdminException("Cannot get roles for filter "
+ + filter, e);
+ }