X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Futil%2Fdirectory%2Fldap%2FAbstractLdapDirectory.java;h=54d9776b5fd15106bf6de8b560ef81f863f1d470;hb=285c23f26c4d634cd139d393ebcb708187d5e960;hp=27c2b9531d6465b3ade47fce8dafcf69cfbc243b;hpb=4012bedd8870634488b307d2233590fb1226e5d4;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/util/directory/ldap/AbstractLdapDirectory.java b/org.argeo.util/src/org/argeo/util/directory/ldap/AbstractLdapDirectory.java index 27c2b9531..54d9776b5 100644 --- a/org.argeo.util/src/org/argeo/util/directory/ldap/AbstractLdapDirectory.java +++ b/org.argeo.util/src/org/argeo/util/directory/ldap/AbstractLdapDirectory.java @@ -161,9 +161,9 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv /* * CREATION */ - protected abstract LdapEntry newUser(LdapName name, Attributes attrs); + protected abstract LdapEntry newUser(LdapName name); - protected abstract LdapEntry newGroup(LdapName name, Attributes attrs); + protected abstract LdapEntry newGroup(LdapName name); /* * EDITION @@ -255,11 +255,11 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv } else { // user doesn't have the right to retrieve role, but we know it exists // otherwise memberOf would not work - Attributes a = new BasicAttributes(); - a.put(LdapNameUtils.getLastRdn(groupDn).getType(), - LdapNameUtils.getLastRdn(groupDn).getValue()); - a.put(LdapAttrs.objectClass.name(), LdapObjs.groupOfNames.name()); - group = newGroup(groupDn, a); +// Attributes a = new BasicAttributes(); +// a.put(LdapNameUtils.getLastRdn(groupDn).getType(), +// LdapNameUtils.getLastRdn(groupDn).getValue()); +// a.put(LdapAttrs.objectClass.name(), LdapObjs.groupOfNames.name()); + group = newGroup(groupDn); allRoles.add(group); } } @@ -267,10 +267,13 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv throw new IllegalStateException("Cannot get memberOf groups for " + user, e); } } else { - for (LdapName groupDn : getDirectoryDao().getDirectGroups(user.getDn())) { - // TODO check for loops + directGroups: for (LdapName groupDn : getDirectoryDao().getDirectGroups(user.getDn())) { LdapEntry group = doGetRole(groupDn); if (group != null) { + if (allRoles.contains(group)) { + // important in order to avoi loops + continue directGroups; + } allRoles.add(group); collectGroups(group, allRoles); } @@ -326,7 +329,7 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv // TODO deal with multiple attr RDN attrs.put(nameRdn.getType(), nameRdn.getValue()); wc.getModifiedData().put(dn, attrs); - LdapHierarchyUnit newHierarchyUnit = new LdapHierarchyUnit(this, dn, attrs); + LdapHierarchyUnit newHierarchyUnit = new LdapHierarchyUnit(this, dn); wc.getNewData().put(dn, newHierarchyUnit); return newHierarchyUnit; } @@ -336,7 +339,7 @@ public abstract class AbstractLdapDirectory implements Directory, XAResourceProv */ @Override - public String getContext() { + public String getBase() { return getBaseDn().toString(); }