Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using string value as variable name for ldap attribute

807588Feb 26 2009 — edited Feb 26 2009
I searched the archives and found some suggestions to use map, but I'm still not sure how to do it. I'm writing a small app that will copy an ldap object. Basically, read the current object, grab all the attirbutes, create a new object somewhere else using all the attributes.

So it would look something like this:
Attribute givenName = new BasicAttribute("givenName", firstName);
Attribute sn = new BasicAttribute("sn", lastName);
Attribute uid = new BasicAttribute("uid", username);

// Add these to the container
container.put(objClasses);
container.put(cn);
container.put(sn);
Since I'm reading all the attributes from an existing object, I don't know them before hand. So if I had an ArrayList of Strings where the first value is the attribute name, and the rest of the array had the values (because some could have more than one) how would I use this in the code?

This is not meant to be code, just showing where I want to use the values.
ArrayList is myValues
(this would be a loop until the end of myValues ArrayList)
Attribute [myValues.get(0)] = new BasicAttribute( [myValues.get(0)], [myValues.get(1)]);
Attribute [myValues.get(0)] = new BasicAttribute( [myValues.get(0)], [myValues.get(2)]);
container.put(myValues.get(0));

I hope that makes sense. How would I do this?

Thanks,
James
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2009
Added on Feb 26 2009
3 comments
217 views