Re: JNDI: Delete only one attribute when there are several different
values for the same attribute
There's something creative about posting to usenet :)
I think i figured it out just after posting the above. What seems to
// attribute, value are the values that I want to remove...
BasicAttribute ba = new BasicAttribute(attribute, value);
BasicAttributes bas = new BasicAttributes();
context.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, bas);
I would still be interested to hear of other approaches, or thoughts
Just wanted to say that I was re-reading your initial post and was
originally thinking you were wanting to delete a value from an attribute
when it had multiple values but it seems you want to delete a whole
attribute. You seem to have been using the word "value" in multiple ways
but in LDAP terminology it means something specific so it threw me off
until I re-read your post.
Going back to your original post, you wanted to only remove the the
sysRole user attribute. Given your example, sysRole is the attribute
but 'user' is the data (you called 'user' an attribute), specifically it
is the 2nd value for the sysRole attribute based on your example.
Depending on whether or not I understand you correctly this time and
whether you correctly used the terms you wanted to use I'll say this:
You are on the right track but you don't have to specify any value to
the BasicAttribute() constructor to delete an attribute. It has another
constructor that takes only an attribute name.