Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

JNDI: Delete only one attribute when there are several different values for the same attribute

Thread view: 
bsporb@gmail.com - 01 May 2007 20:21 GMT
Hi;

My user entry has several role attributes, each with different values.

Can I use context.modifyAttributes() to remove only one of these
values?

Example:

DN uid=foo,ou=People,o=us.org

Attributes:
...
sysRole developer
sysRole user
sysRole tester
...

how would I remove only the user role attribute?

thanks for any help.

-sporb
bsporb@gmail.com - 01 May 2007 21:01 GMT
There's something creative about posting to usenet :)

I think i figured it out just after posting the above.  What seems to
work:

// attribute, value are the values that I want to remove...
BasicAttribute ba = new BasicAttribute(attribute, value);
BasicAttributes bas = new BasicAttributes();
bas.put(ba);
context.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, bas);

I would still be interested to hear of other approaches, or thoughts
on this.

thanks again
-sporb
Brandon McCombs - 02 May 2007 06:25 GMT
> There's something creative about posting to usenet :)
>
[quoted text clipped - 12 lines]
> thanks again
> -sporb

I haven't ever tried your idea with my own app that utilizes JNDI but I
would think that on the surface, your code would remove the attribute
and any values it contained but if you say it works then it must be okay.

I, on the other hand, take the opposite approach. I ignore any values
that will be removed and create a new BasicAttribute that contains only
the values that will be kept and write that back to the directory store
using modifyAttributes().
Brandon McCombs - 02 May 2007 06:41 GMT
> There's something creative about posting to usenet :)
>
[quoted text clipped - 12 lines]
> thanks again
> -sporb

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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.