public LdapGroup addMember(final LdapObject< ? > member, final String baseDN) { return addMember(member.getDn(), baseDN); }
public void add(final LdapObject< ? > obj) { setOfDNs.add(obj.getDn()); if (obj.getId() != null) { setOfIds.add(obj.getId()); } }
/** * Set of all objects (the string is built from the method {@link #buildDn(Object)}). */ public SetOfAllLdapObjects getSetOfAllObjects(final String organizationalUnit) { final SetOfAllLdapObjects set = new SetOfAllLdapObjects(); final List<T> all = findAll(organizationalUnit); for (final T obj : all) { if (log.isDebugEnabled() == true) { log.debug("Adding: " + obj.getDn()); } set.add(obj); } return set; }
/** * Set of all objects (the string is built from the method {@link #buildDn(Object)}). * * @throws NamingException */ public SetOfAllLdapObjects getSetOfAllObjects(final DirContext ctx, final String organizationalUnit) throws NamingException { final SetOfAllLdapObjects set = new SetOfAllLdapObjects(); final List<T> all = findAll(ctx, organizationalUnit); for (final T obj : all) { if (log.isDebugEnabled() == true) { log.debug("Adding: " + obj.getDn()); } set.add(obj); } return set; }
/** * Sets dn of object and organizationalUnit if not already given. * * @param ouBase If {@link T#getOrganizationalUnit()} is not given, ouBase is used for building dn, otherwise ouBase * is ignored. * @param obj * @return */ protected String buildDn(final String ouBase, final T obj) { final StringBuffer buf = new StringBuffer(); buf.append(buildDnIdentifier(obj)); if (obj.getOrganizationalUnit() != null) { buf.append(','); LdapUtils.buildOu(buf, obj.getOrganizationalUnit()); } else if (ouBase != null) { buf.append(','); LdapUtils.buildOu(buf, ouBase); obj.setOrganizationalUnit(ouBase); } obj.setDn(buf.toString()); return obj.getDn(); }
public void modify(final DirContext ctx, final T obj, final List<ModificationItem> modificationItems) throws NamingException { final Object id = getId(obj); // The dn is may-be changed, so find the original dn by id: final T origObject = findById(ctx, id, obj.getOrganizationalUnit()); if (origObject == null) { throw new RuntimeException("Object with id " + id + " not found in search base '" + StringHelper.listToString(",", obj.getOrganizationalUnit()) + "'. Can't modify the object: " + obj); } final String dn = origObject.getDn(); log.info("Modify attributes of " + getObjectClass() + ": " + dn + ": " + getLogInfo(obj)); if (log.isDebugEnabled()) { for (ModificationItem mi : modificationItems) { if (mi != null) log.debug("\t" + mi.toString()); } } final ModificationItem[] items = modificationItems.toArray(new ModificationItem[modificationItems.size()]); ctx.modifyAttributes(dn, items); // Don't move object. // if (obj.getDn() != null && StringUtils.equals(dn, obj.getDn()) == false) { // log.info("DN of object is changed from '" + dn + "' to '" + obj.getDn()); // ctx.rename(dn, obj.getDn()); // } }