Hello,
I update a attribute with multiple values in the following manner:
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.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);
Is there not a more elegant solution for this. Something like addValueToAttribute(String attribute, String value)??


Reply With Quote
