Back Forum Reply New

simpleLdapTemplate

I'm successfully using simpleLdapTemplate for all of my ldap CRUD operations; however, I cannot find a way to actually remove a particular attribute from an entry.  I can only set the attribute value to empty or null but cannot find a way to set the equivalent DirContext.REMOVE_ATTRIBUTE ModificationItem.  

Is there a way to use simpleLdapTemplate and still have this granular level of control?

AFAIK, there is no direct method in SimpleLdapTempalte to remove an attribute. However, you can use the SimpleLdapTemplate to get an instnace of LdapOperations and use it to remove an attribute. Here is some code that can help you:Code:   public void removeAttribute(String dn, String name, String value)   {   ModificationItem[] items = new ModificationItem[]{    new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute(name, value))       };   LdapOperations ldapOperations = ldapTemplate.getLdapOperations();       ldapOperations.modifyAttributes(dn, items);       }
¥
Back Forum Reply New