X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.core%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdapUserAdmin.java;h=22d9a54227b383d629f13e6be760731bd01b972d;hb=0b8aa4c76cb7a1d19abf93a4c1ae0c973abdab5b;hp=17bbc3733e405897ec8655a1dbc739a7646f5b0f;hpb=51cc1040b4154fa2968f17f97a206ec838f7abc1;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.core/src/org/argeo/osgi/useradmin/LdapUserAdmin.java b/org.argeo.security.core/src/org/argeo/osgi/useradmin/LdapUserAdmin.java index 17bbc3733..22d9a5422 100644 --- a/org.argeo.security.core/src/org/argeo/osgi/useradmin/LdapUserAdmin.java +++ b/org.argeo.security.core/src/org/argeo/osgi/useradmin/LdapUserAdmin.java @@ -10,6 +10,7 @@ import java.util.List; import javax.naming.Binding; import javax.naming.Context; import javax.naming.InvalidNameException; +import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attribute; @@ -106,7 +107,7 @@ public class LdapUserAdmin extends AbstractUserDirectory { + name); return res; } catch (NamingException e) { - throw new UserDirectoryException("Cannot get role for " + name, e); + return null; } } @@ -127,7 +128,6 @@ public class LdapUserAdmin extends AbstractUserDirectory { results: while (results.hasMoreElements()) { SearchResult searchResult = results.next(); Attributes attrs = searchResult.getAttributes(); - log.debug(attrs.isCaseIgnored()); Attribute objectClassAttr = attrs.get(objectClass.name()); LdapName dn = toDn(searchBase, searchResult); LdifUser role; @@ -194,14 +194,14 @@ public class LdapUserAdmin extends AbstractUserDirectory { } // add for (LdapName dn : wc.getNewUsers().keySet()) { - if (!entryExists(dn)) + if (entryExists(dn)) throw new UserDirectoryException("User to create found " + dn); } // modify for (LdapName dn : wc.getModifiedUsers().keySet()) { if (!entryExists(dn)) - throw new UserDirectoryException("User to modify no found " + throw new UserDirectoryException("User to modify not found " + dn); } } catch (NamingException e) { @@ -210,7 +210,11 @@ public class LdapUserAdmin extends AbstractUserDirectory { } private boolean entryExists(LdapName dn) throws NamingException { - return getLdapContext().getAttributes(dn).size() != 0; + try { + return getLdapContext().getAttributes(dn).size() != 0; + } catch (NameNotFoundException e) { + return false; + } } @Override