Le 04/03/15 13:31, Syed Mudassir a écrit :
> Hi.
> I am using apache directory api in my java program to interact with ldap
> server.
> Upon performing successful search, I am able to get the Entry object.
> But the Entry object has a method getAttributes() which will return a
> collection of Attribute.
> If an Attribute contains multiple values, how can I fetch all those values?
> Presently, I see only method get() which will fetch just the first value.
> --
You have to use the iterator(). The best way to do that is :
Attribute myAttribute = entry.get( "MyAttribute" );
for ( Value<?> value : myAttribute )
{
// do what you need to do with your value
}
or :
Iterator<Value<?>> iterator = myAttribute.iterator();
while ( iterator.hasNext() )
{
Value<?> value = iterator.next();
// ...
}
which is a bit more verbose.