Results 1 to 2 of 2

Thread: better way to update multiple values attribute

  1. #1

    Default better way to update multiple values attribute

    Hello,

    I update a attribute with multiple values in the following manner:
    Code:
    Name dn = buildGroupDn(ldapUser, role);
    logger.debug("addToGroup:dn is " + dn.toString());
    DirContextOperations context = ldapTemplate.lookupContext(dn);
    mapToGroupContext(ldapUser, role, context);
    		
    // add user
    String[] members =  context.getStringAttributes(UserDaoLdapImpl.UNIQUE_MEMBER);
    		members = (String[]) ArrayUtils.add(members, "uid=" + ldapUser.getUid() + ",ou=" + ldapUser.getCompany() + "dc=xx,dc=yy");
    		
    context.setAttributeValues(UserDaoLdapImpl.UNIQUE_MEMBER, members);
    ldapTemplate.modifyAttributes(context);
    I first take all the values of the attribute in a Collection and then add my change to the collection and then save this collection as the attribute change.

    Is there not a more elegant solution for this. Something like addValueToAttribute(String attribute, String value)??

  2. #2
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    The method you are looking for is called addAttributeValue().
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •