You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Emilio Recio <er...@polywog.org> on 2013/02/12 20:47:25 UTC
Retrieving over multi-valued attributes
I am kind of stuck on how to get ALL of the attribute's values.
Currently, I am Binding as the user (using LdapNetworkConnection). I am
getting an EntryCursor via search method of that. I am retrieving an
Entry from the cursor.get() method. I get a collection<attribute> list
of attributes. I can cycle through each of the entry's attributes but
whatever I do, I cannot find in the API where I can get more than just
the first value.
I have tried:
Collection<Attribute> attrs = entry.getAttributes();
for (Attribute attr : attrs) {
_log.debug("ATTR: " + attr.getId());
_log.debug("VALX: " + attr.size());
Value<?> vals = attr.get();
for (int i = 0;i < vals.length(); i++ ) {
????
}
For example, I am taking the objectClass attribute.
--
Thanks,
E. Recio
Live within your income, even if you have to borrow to do so.
-- Josh Billings
Re: Retrieving over multi-valued attributes
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 2/12/13 8:47 PM, Emilio Recio a écrit :
> I am kind of stuck on how to get ALL of the attribute's values.
> Currently, I am Binding as the user (using LdapNetworkConnection). I
> am getting an EntryCursor via search method of that. I am retrieving
> an Entry from the cursor.get() method. I get a collection<attribute>
> list of attributes. I can cycle through each of the entry's attributes
> but whatever I do, I cannot find in the API where I can get more than
> just the first value.
>
> I have tried:
>
> Collection<Attribute> attrs = entry.getAttributes();
> for (Attribute attr : attrs) {
> _log.debug("ATTR: " + attr.getId());
> _log.debug("VALX: " + attr.size());
>
> Value<?> vals = attr.get();
> for (int i = 0;i < vals.length(); i++ ) {
> ????
> }
>
>
> For example, I am taking the objectClass attribute.
>From the top of my head :
for (Attribute attr : entry) {
_log.debug("ATTR: " + attr.getId());
_log.debug("VALX: " + attr.size());
for ( Value<?> value : attr) {
// You have all the values one by one
}
}
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com