directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Ayyagari <kayyag...@apache.org>
Subject Re: Search problems
Date Sat, 21 Mar 2015 15:19:17 GMT
On Sat, Mar 21, 2015 at 10:29 PM, Claudio <clamun@gmail.com> wrote:

> Hello friends,
>
> I want to list all the mails that have an entry in my ldap server.
>
you mean you want to list all the mail addresses present in each entry?

>
> My code is:
>
>
>
> LdapConnection connection =new LdapNetworkConnection(hostname));
>   connection().bind(adminLDAP, password);
>
>                 ArrayList<String> mailList = new ArrayList<String>();
>
> EntryCursor cursor = connection().search( dnUser, "(mail=*)",
> SearchScope.SUBTREE );
> Entry resultSearch= null;
>  while ( cursor.next() )
> {
>
>  resultSearch = cursor.get();
>    Attribute attr = resultSearch.get("mail");
>    mailList.add(attr.getString());
>
>
>  }
>
>
>
> This code lists only one mail for each of the entry not everyone who has.
>
mail is a multivalued attribute, so you  need to iterate on the 'attr'
reference and
get all the values instead of calling attr.getString(), which returns only
one of those present.

>
> I need help with this
>
>
> thank you very much
>



-- 
Kiran Ayyagari
http://keydap.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message