Directory as a hierarchy unit.
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / LdapDao.java
index 8e26cb44f14125206446e23eb0cf0849f26ebe50..d93fb7fdf62074d5be80f53563a41992bb50aa69 100644 (file)
@@ -246,7 +246,9 @@ public class LdapDao extends AbstractLdapDirectoryDao {
        public HierarchyUnit doGetHierarchyUnit(LdapName dn) {
                try {
                        if (getDirectory().getBaseDn().equals(dn))
-                               return null;
+                               return getDirectory();
+                       if (!dn.startsWith(getDirectory().getBaseDn()))
+                               throw new IllegalArgumentException(dn + " does not start with abse DN " + getDirectory().getBaseDn());
                        Attributes attrs = ldapConnection.getAttributes(dn);
                        return new LdapHierarchyUnit(getDirectory(), dn, attrs);
                } catch (NamingException e) {