+ /*
+ * HIERARCHY
+ */
+
+ @Override
+ protected Iterable<HierarchyUnit> doGetDirectHierarchyUnits(LdapName searchBase, boolean functionalOnly) {
+ List<HierarchyUnit> res = new ArrayList<>();
+ try {
+ String searchFilter = "(|(" + objectClass + "=" + LdapObjs.organizationalUnit.name() + ")(" + objectClass
+ + "=" + LdapObjs.organization.name() + "))";
+
+ SearchControls searchControls = new SearchControls();
+ searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+
+ NamingEnumeration<SearchResult> results = ldapConnection.search(searchBase, searchFilter, searchControls);
+
+ while (results.hasMoreElements()) {
+ SearchResult searchResult = (SearchResult) results.nextElement();
+ LdapName dn = toDn(searchBase, searchResult);
+ Attributes attrs = searchResult.getAttributes();
+ LdifHierarchyUnit hierarchyUnit = new LdifHierarchyUnit(this, dn, attrs);
+ if (hierarchyUnit.isFunctional())
+ res.add(hierarchyUnit);
+ }
+ return res;
+ } catch (NamingException e) {
+ throw new IllegalStateException("Cannot get direct hierarchy units ", e);
+ }
+ }
+
+ @Override
+ protected HierarchyUnit doGetHierarchyUnit(LdapName dn) {
+ try {
+ Attributes attrs = ldapConnection.getAttributes(dn);
+ return new LdifHierarchyUnit(this, dn, attrs);
+ } catch (NamingException e) {
+ throw new IllegalStateException("Cannot get hierarchy unit " + dn, e);
+ }
+ }