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;
+ name);
return res;
} catch (NamingException e) {
- throw new UserDirectoryException("Cannot get role for " + name, e);
+ return null;
}
}
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;
}
// 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) {
}
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