Fix glitches while testing the Security Perspective with LDAP backend
authorBruno Sinou <bsinou@argeo.org>
Wed, 6 Apr 2016 14:06:16 +0000 (14:06 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 6 Apr 2016 14:06:16 +0000 (14:06 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8860 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.security.core/src/org/argeo/osgi/useradmin/LdapUserAdmin.java

index 7acb7dffd915808a7297ed09f336b9015aa11070..22d9a54227b383d629f13e6be760731bd01b972d 100644 (file)
@@ -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;
@@ -200,7 +201,7 @@ public class LdapUserAdmin extends AbstractUserDirectory {
                        // 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) {
@@ -209,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