X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Futil%2Fdirectory%2Fldap%2FLdapDao.java;h=e15c005bef38771bedd3a84d7692d8c4e336113c;hb=b9810eb23f4e2470952a04c07d15a523c3c61a0e;hp=c33b50f65fb9a1a781bb62de4535b63b25198c63;hpb=4d675e1c871cfd8e4481e03cd496ab975b8b367d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/util/directory/ldap/LdapDao.java b/org.argeo.util/src/org/argeo/util/directory/ldap/LdapDao.java index c33b50f65..e15c005be 100644 --- a/org.argeo.util/src/org/argeo/util/directory/ldap/LdapDao.java +++ b/org.argeo.util/src/org/argeo/util/directory/ldap/LdapDao.java @@ -68,29 +68,34 @@ public class LdapDao extends AbstractLdapDirectoryDao { @Override public Boolean entryExists(LdapName dn) { try { - return doGetEntry(dn) != null; + return ldapConnection.entryExists(dn); } catch (NameNotFoundException e) { return false; + } catch (NamingException e) { + throw new IllegalStateException("Cannot check " + dn, e); } } @Override public LdapEntry doGetEntry(LdapName name) throws NameNotFoundException { - try { - Attributes attrs = ldapConnection.getAttributes(name); - if (attrs.size() == 0) - return null; + if (!entryExists(name)) + throw new NameNotFoundException(name + " was not found in " + getDirectory().getBaseDn()); +// try { +// Attributes attrs = ldapConnection.getAttributes(name); +// if (attrs.size() == 0) +// return null; + // int roleType = roleType(name); LdapEntry res; Rdn technicalRdn = LdapNameUtils.getParentRdn(name); if (getDirectory().getGroupBaseRdn().equals(technicalRdn)) - res = newGroup(name, attrs); + res = newGroup(name, null); else if (getDirectory().getSystemRoleBaseRdn().equals(technicalRdn)) - res = newGroup(name, attrs); + res = newGroup(name, null); else if (getDirectory().getUserBaseRdn().equals(technicalRdn)) - res = newUser(name, attrs); + res = newUser(name, null); else - res = new DefaultLdapEntry(getDirectory(), name, attrs); + res = new DefaultLdapEntry(getDirectory(), name, null); // if (isGroup(name)) // res = newGroup(name, attrs); // else @@ -98,11 +103,9 @@ public class LdapDao extends AbstractLdapDirectoryDao { // else // throw new IllegalArgumentException("Unsupported LDAP type for " + name); return res; - } catch (NameNotFoundException e) { - throw e; - } catch (NamingException e) { - return null; - } +// } catch (NameNotFoundException e) { +// throw e; +// } } // protected boolean isGroup(LdapName dn) { @@ -117,6 +120,16 @@ public class LdapDao extends AbstractLdapDirectoryDao { // "Cannot find role type, " + technicalRdn + " is not a technical RDN for " + dn); // } + @Override + public Attributes doGetAttributes(LdapName name) { + try { + Attributes attrs = ldapConnection.getAttributes(name); + return attrs; + } catch (NamingException e) { + throw new IllegalStateException("Cannot get attributes for " + name); + } + } + @Override public List doGetEntries(LdapName searchBase, String f, boolean deep) { ArrayList res = new ArrayList<>();