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 44E1D1188F for ; Wed, 6 Aug 2014 08:03:36 +0000 (UTC) Received: (qmail 81415 invoked by uid 500); 6 Aug 2014 08:03:36 -0000 Delivered-To: apmail-directory-api-archive@directory.apache.org Received: (qmail 81306 invoked by uid 500); 6 Aug 2014 08:03:36 -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 81282 invoked by uid 99); 6 Aug 2014 08:03:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 08:03:35 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of er.prabhjots@gmail.com designates 209.85.217.172 as permitted sender) Received: from [209.85.217.172] (HELO mail-lb0-f172.google.com) (209.85.217.172) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 08:03:31 +0000 Received: by mail-lb0-f172.google.com with SMTP id z11so1621986lbi.17 for ; Wed, 06 Aug 2014 01:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lvVL9RYnvpcU1+asfReYb2jpyQY9LQ7VRGHFLay3pi0=; b=n3p595nSR4+umMnnFQ/cT5bC0znJbMz02iLYzFyhXoIUpSj0jCvHVFljhu1lkxNu6A 4mjsGQBFw0oeIznM1uSWeLv1m93FzMmrybE5ErU00s+V9lkJ7bZFv+up8xeoyulLOdFx 1l+dcCyynofz/GuJ4IPram8C7Y+iJZ8EX1S0kt2zIfvwdnHrOYBK7RMC5OM4fbG5KJHq gsSJ9ZHHkwND2hd1mJgaqqw6YnuRMNZTEUisEsu3Ph1QnzosHFLkWBK5/xMp+s0eMolv rOVdp1/U/mDU+Q3qG/SzZ8RWXhvzECPpCJoOBR9NZsiv/3NmDajKwGOxmyuElftgFqDP f/1w== MIME-Version: 1.0 X-Received: by 10.112.209.36 with SMTP id mj4mr919297lbc.26.1407312189267; Wed, 06 Aug 2014 01:03:09 -0700 (PDT) Received: by 10.112.12.197 with HTTP; Wed, 6 Aug 2014 01:03:09 -0700 (PDT) In-Reply-To: References: <5e7349970f50f9383c0f47474c4c716c@mail.gmail.com> <53e10d0c.6ace440a.0eb7.6609@mx.google.com> Date: Wed, 6 Aug 2014 13:33:09 +0530 Message-ID: Subject: Re: Apache LDAP API - ActiveDirectory Handling referrals From: prabhjot singh To: Kiran Ayyagari Cc: "users@directory.apache.org" , api@directory.apache.org Content-Type: multipart/alternative; boundary=001a11c25eba21242c04fff16723 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c25eba21242c04fff16723 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Kiran. I'm not very clear how to achieve this using LdapNetworkConnection. If I understand correctly, I see we've LdapNetworkConnection.search(SearchRequest request) and set the followReferrals on the search request passed here (the way I was doing in my code snippet)? Also, I'm not terribly familiar with how to process SearchCursor and specifically handle referrals (if I've to do this). Will appreciate if you can point to some example code. On Tue, Aug 5, 2014 at 10:35 PM, Kiran Ayyagari wrote: > > > > On Tue, Aug 5, 2014 at 10:27 PM, prabhjot singh > wrote: > >> Thanks Kiran. That would mean LdapConnectionTemplate won't be safe to us= e >> in any of the search operations. >> >> it is not about safety, just that this template class decided not to > support referrals > >> Is it safe to use LdapConnectionTemplate for lookup operations at least? >> > yes, you can use, but you will face the same issue if a referral entry is > recieved during lookup > > Looks like you are making heavy use of template in your code, if so, may > be you can just extend > the template to support referral entries or use LdapNetworkConnection > directly. > >> >> Thanks, >> Prabhjot >> ------------------------------ >> From: Kiran Ayyagari >> Sent: =E2=80=8E8/=E2=80=8E5/=E2=80=8E2014 10:19 PM >> To: api@directory.apache.org; users@directory.apache.org >> Cc: er.prabhjots@gmail.com >> Subject: Re: Apache LDAP API - ActiveDirectory Handling referrals >> >> >> >> >> On Tue, Aug 5, 2014 at 9:45 PM, Prabhjot Singh > > wrote: >> >>> Hi Experts, >>> >>> >>> >>> Can you please point me on how to handle referrals in the search >>> operation? >>> I want the logic to follow the referrals so it collects results from al= l >>> Active Directory DCs. I get below exception even with followReferrals s= et >>> to true. >>> >>> >>> >>> public List getAllGroups(String customer, String baseDn) throws >>> Exception { >>> >>> LdapConnectionTemplate connection =3D >>> connections.getLdapConnectionTemplate(customer); >>> >>> LdapConnectionTemplate doesn't support referrals, so search using >> LdapNetworkConnection directly >> >>> SearchRequest searchRequest =3D connection.newSearchRequest(bas= eDn, >>> "(objectclass=3DorganizationalUnit)", SearchScope.ONELEVEL, >>> GROUP_ATTRIBUTES); >>> >>> searchRequest =3D searchRequest.followReferrals(); >>> >>> return connection.search(searchRequest, new GroupMapper()); >>> >>> } >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> java.lang.RuntimeException: ERR_02002_FAILURE_ON_UNDERLYING_CURSOR >>> Failure >>> on underlying Cursor. >>> >>> at >>> >>> org.apache.directory.api.ldap.model.cursor.CursorIterator.next(CursorIt= erator.java:86) >>> >>> at >>> >>> org.apache.directory.ldap.client.template.LdapConnectionTemplate.search= (LdapConnectionTemplate.java:662) >>> >>> at >>> >>> com.kaseya.mobility.directory.core.dao.group.DirectoryDetailsDaoImpl.ge= tAllGroups(DirectoryDetailsDaoImpl.java:53) >>> >>> at >>> >>> com.kaseya.mobility.directory.core.dao.group.DirectoryDetailsDaoImplTes= t.testGetAllGroups(DirectoryDetailsDaoImplTest.java:66) >>> >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native >>> Method) >>> >>> at >>> >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja= va:57) >>> >>> at >>> >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso= rImpl.java:43) >>> >>> at >>> >>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMe= thod.java:44) >>> >>> at >>> >>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCalla= ble.java:15) >>> >>> at >>> >>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMeth= od.java:41) >>> >>> at >>> >>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMetho= d.java:20) >>> >>> at >>> >>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.ja= va:28) >>> >>> at >>> >>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunne= r.java:76) >>> >>> at >>> >>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunne= r.java:50) >>> >>> at >>> org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) >>> >>> at >>> org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) >>> >>> at >>> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) >>> >>> at >>> org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) >>> >>> at >>> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) >>> >>> at >>> org.junit.runners.ParentRunner.run(ParentRunner.java:236) >>> >>> at org.junit.runner.JUnitCore.run(JUnitCore.java:157) >>> >>> at >>> >>> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4Idea= TestRunner.java:74) >>> >>> at >>> >>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUn= itStarter.java:211) >>> >>> at >>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) >>> >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native >>> Method) >>> >>> at >>> >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja= va:57) >>> >>> at >>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) >>> >>> Caused by: >>> org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException >>> >>> at >>> >>> org.apache.directory.ldap.client.api.EntryCursorImpl.get(EntryCursorImp= l.java:164) >>> >>> at >>> >>> org.apache.directory.ldap.client.api.EntryCursorImpl.get(EntryCursorImp= l.java:50) >>> >>> at >>> >>> org.apache.directory.api.ldap.model.cursor.CursorIterator.next(CursorIt= erator.java:80) >>> >>> ... 29 more >>> >> >> >> >> -- >> Kiran Ayyagari >> http://keydap.com >> > > > > -- > Kiran Ayyagari > http://keydap.com > --=20 Thanks, Prabhjot --001a11c25eba21242c04fff16723--