Return-Path: X-Original-To: apmail-directory-api-archive@minotaur.apache.org Delivered-To: apmail-directory-api-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 73C481756C for ; Sat, 21 Mar 2015 22:09:15 +0000 (UTC) Received: (qmail 95631 invoked by uid 500); 21 Mar 2015 22:09:15 -0000 Delivered-To: apmail-directory-api-archive@directory.apache.org Received: (qmail 95589 invoked by uid 500); 21 Mar 2015 22:09:15 -0000 Mailing-List: contact api-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: api@directory.apache.org Delivered-To: mailing list api@directory.apache.org Received: (qmail 95577 invoked by uid 99); 21 Mar 2015 22:09:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Mar 2015 22:09:15 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of elecharny@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-we0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Mar 2015 22:09:08 +0000 Received: by webcq43 with SMTP id cq43so108383508web.2 for ; Sat, 21 Mar 2015 15:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=WQC0F0mm1RuGmuISLvS8u5GpN1fzTbXsTPNRBXpXR4I=; b=RbWayO5MoksJLCKgsoayv3xHPFlZBd0TpEWvcs8HIm++VWy1/gSYClo84aMegZ6ANW rqkLWb8ZrqpoDrY1egYEuBAWWAHRI9pV/3X2rufcdpqV4ZOKVVW1TDwVYPmNUxeyVi2L msVK8iavDUVbBkMU6xWAeeobjfr9JOGBPivyrv1bBNMOhGCUUYKUEqSCnF+NoZOnyOrA nBT1tDnYw3EVRxY6dZpEYABboTHi9DgfKrTVT8LTqlfj4FHsWI8eHi4h+xSsbm4bJV9K 3yENJoEr1YfJOb975YTpE1FDZwAmxvWUIUOL5hLgR9ZuRUxHd+OtLBAH9opeuePyDFTK fGaA== X-Received: by 10.180.104.33 with SMTP id gb1mr7146010wib.33.1426975682510; Sat, 21 Mar 2015 15:08:02 -0700 (PDT) Received: from [192.168.1.20] (AMontsouris-651-1-10-164.w90-46.abo.wanadoo.fr. [90.46.101.164]) by mx.google.com with ESMTPSA id cf12sm12331641wjb.10.2015.03.21.15.08.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Mar 2015 15:08:01 -0700 (PDT) Message-ID: <550DEBC1.5090801@gmail.com> Date: Sat, 21 Mar 2015 23:08:01 +0100 From: =?UTF-8?B?RW1tYW51ZWwgTMOpY2hhcm55?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: api@directory.apache.org Subject: Re: Search problems References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Le 21/03/15 16:19, Kiran Ayyagari a écrit : > On Sat, Mar 21, 2015 at 10:29 PM, Claudio 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 mailList = new ArrayList(); >> >> 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. Which is done with such a code : while ( cursor.next() ) { resultSearch = cursor.get(); for ( Value mail : resultSearch.getA("mail") ) { mailList.add(mail.getSTring()); } } > >> I need help with this >> >> >> thank you very much >> > >