@SuppressWarnings("unchecked") protected void addMemberOf(Fixture fixture, LdapTemplate template, String user) throws NamingException { List<String> dns = template.search( "", fixture.config.usernameFilter(user).encode(), new ContextMapper() { public Object mapFromContext(Object arg0) { DirContextAdapter ctx = (DirContextAdapter) arg0; return ctx.getNameInNamespace(); } }); assertEquals(dns.toString(), 1, dns.size()); DistinguishedName name = new DistinguishedName(dns.get(0)); DistinguishedName root = new DistinguishedName( template.getContextSource().getReadOnlyContext().getNameInNamespace()); // Build a relative name for (int i = 0; i < root.size(); i++) { name.removeFirst(); } DirContextOperations context = template.lookupContext(name); context.setAttributeValues("memberOf", new Object[] {"foo"}); template.modifyAttributes(context); }
@Override public void update(Person person) { Name dn = buildDn(person); DirContextAdapter context = (DirContextAdapter) ldapTemplate.lookup(dn); mapToContext(person, context); ldapTemplate.modifyAttributes(dn, context.getModificationItems()); }
/** * Update the user's photo. * * @param p */ public void updatePhoto(ContactDTO contact) { Attribute attr = new BasicAttribute("jpegPhoto", contact.getJpegPhoto()); ModificationItem item = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr); ldapTemplate.modifyAttributes("cn=" + contact.getCommonName(), new ModificationItem[] {item}); }
public void updateResource(Resource resource, ModificationItem[] modificationItems) { ldapTemplate.modifyAttributes( getResourceDN(String.valueOf(resource.getVoId()), String.valueOf(resource.getId())), modificationItems); log.debug("Entry modified in LDAP: Resource {}.", resource); }
public void updateUserWithUserId(String userId, ModificationItem[] modificationItems) { ldapTemplate.modifyAttributes(getUserDN(userId), modificationItems); log.debug("Entry modified in LDAP: UserId {}.", userId); }
public void updateUsersLibraryIds(String userId, String[] libraryIDs) { DirContextOperations context = ldapTemplate.lookupContext(getUserDN(userId)); context.setAttributeValues("libraryIDs", libraryIDs); ldapTemplate.modifyAttributes(context); log.debug("Entry modified in LDAP: UserId {}.", userId); }
public void updateUsersCertSubjects(String userId, String[] certSubjects) { DirContextOperations context = ldapTemplate.lookupContext(getUserDN(userId)); context.setAttributeValues("userCertificateSubject", certSubjects); ldapTemplate.modifyAttributes(context); log.debug("Entry modified in LDAP: UserId {}.", userId); }
public void updateVo(int voId, ModificationItem[] modificationItems) { ldapTemplate.modifyAttributes(getVoDNByVoId(String.valueOf(voId)), modificationItems); log.debug("Entry modified in LDAP: Vo {}.", voId); }
public void updateGroup(Group group, ModificationItem[] modificationItems) { ldapTemplate.modifyAttributes( getGroupDN(String.valueOf(group.getVoId()), String.valueOf(group.getId())), modificationItems); log.debug("Entry modified in LDAP: Group {}.", group); }