示例#1
0
  @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);
  }
示例#2
0
 @Override
 public void update(Person person) {
   Name dn = buildDn(person);
   DirContextAdapter context = (DirContextAdapter) ldapTemplate.lookup(dn);
   mapToContext(person, context);
   ldapTemplate.modifyAttributes(dn, context.getModificationItems());
 }
示例#3
0
 /**
  * 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});
 }
示例#4
0
 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);
 }
示例#5
0
 public void updateUserWithUserId(String userId, ModificationItem[] modificationItems) {
   ldapTemplate.modifyAttributes(getUserDN(userId), modificationItems);
   log.debug("Entry modified in LDAP: UserId {}.", userId);
 }
示例#6
0
 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);
 }
示例#7
0
 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);
 }
示例#8
0
 public void updateVo(int voId, ModificationItem[] modificationItems) {
   ldapTemplate.modifyAttributes(getVoDNByVoId(String.valueOf(voId)), modificationItems);
   log.debug("Entry modified in LDAP: Vo {}.", voId);
 }
示例#9
0
 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);
 }