Uploaded image for project: 'Directory Client API'
  1. Directory Client API
  2. DIRAPI-89

EntryCursorImpl loops forever in next() when using AD Server with referrals

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-M12
    • Fix Version/s: 1.0.0-M14
    • Environment:
      Mac

      Description

      Search for a user that doesn’t exist on AD. Cursor provides four referrals, but no SearchResultDone.

      val searchArg = "(&(objectclass=%s)(samaccountname=%s))".format(s.objectClass, user)
      val cursor = connection.search(s.baseDn, searchArg, SearchScope.SUBTREE, "*")

      next() hangs in this loop ending on line 102:
      while ( !( response instanceof SearchResultDone ) );

      Using this code instead causes a SearchResultDone to appear after three referrals:

      val searchRequest = new SearchRequestImpl().setBase(new Dn(s.baseDn))
      .setFilter(searchArg).setScope(SearchScope.SUBTREE).addControl(new ManageDsaITImpl())

        Activity

        Hide
        akarasulu Alex Karasulu added a comment -

        AD Server = Active Directory Server, or Apache Directory Server?

        Show
        akarasulu Alex Karasulu added a comment - AD Server = Active Directory Server, or Apache Directory Server?
        Hide
        dcbriccetti Dave Briccetti added a comment -

        Active Directory Server

        Show
        dcbriccetti Dave Briccetti added a comment - Active Directory Server
        Hide
        elecharny Emmanuel Lecharny added a comment -
        Show
        elecharny Emmanuel Lecharny added a comment - Should be fixed with http://svn.apache.org/viewvc?rev=1423514&view=rev
        Hide
        duckman Lucas Here;d added a comment -

        Maybe its a different issue (I am having trouble running from source so I can only profile and see its getting stuck in next()), but it is still happening to me after updating to M13.

        Show
        duckman Lucas Here;d added a comment - Maybe its a different issue (I am having trouble running from source so I can only profile and see its getting stuck in next()), but it is still happening to me after updating to M13.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        M13 is still buggy. The patch has been applied to trunk. You should build the code from trunk to check if it's fixed or not.

        If it's not, I'd be happy to fix the fix

        Show
        elecharny Emmanuel Lecharny added a comment - M13 is still buggy. The patch has been applied to trunk. You should build the code from trunk to check if it's fixed or not. If it's not, I'd be happy to fix the fix
        Hide
        duckman Lucas Here;d added a comment -

        I cant figure out how to compile a new version from svn, so i will wait patiently for M14. And yes, I seem to have become one of "those guys" on the bug Thanks for the quick reply .

        Show
        duckman Lucas Here;d added a comment - I cant figure out how to compile a new version from svn, so i will wait patiently for M14. And yes, I seem to have become one of "those guys" on the bug Thanks for the quick reply .
        Hide
        elecharny Emmanuel Lecharny added a comment -

        The fact is that the API does not currently support referrals. The problem is that it should not ends with an infinite loop :/

        Seems like we have to support Referral ! Ok, then...

        Show
        elecharny Emmanuel Lecharny added a comment - The fact is that the API does not currently support referrals. The problem is that it should not ends with an infinite loop :/ Seems like we have to support Referral ! Ok, then...
        Hide
        elecharny Emmanuel Lecharny added a comment -

        I have a minimal fix. We now handle referral by throwing a CursorLdapReferralException. The client code to handle this case would look like :

        EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)",
        SearchScope.SUBTREE, "*", "+" );
        Entry entry = null;
        List<String> refs = new ArrayList<String>();

        while ( cursor.next() )
        {
        try

        { entry = cursor.get(); }

        catch ( CursorLdapReferralException clre )
        {
        do

        { String ref = clre.getReferralInfo(); refs.add( ref ); }

        while ( clre.skipReferral() );
        }
        }

        A test has been added to demonstrate it.

        Show
        elecharny Emmanuel Lecharny added a comment - I have a minimal fix. We now handle referral by throwing a CursorLdapReferralException. The client code to handle this case would look like : EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*", "+" ); Entry entry = null; List<String> refs = new ArrayList<String>(); while ( cursor.next() ) { try { entry = cursor.get(); } catch ( CursorLdapReferralException clre ) { do { String ref = clre.getReferralInfo(); refs.add( ref ); } while ( clre.skipReferral() ); } } A test has been added to demonstrate it.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Forgot to add the commit

        Show
        elecharny Emmanuel Lecharny added a comment - Forgot to add the commit
        Show
        elecharny Emmanuel Lecharny added a comment - Fixed with http://svn.apache.org/viewvc?rev=1424916&view=rev
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Closing the resolved issues.

        Show
        elecharny Emmanuel Lecharny added a comment - Closing the resolved issues.

          People

          • Assignee:
            elecharny Emmanuel Lecharny
            Reporter:
            dcbriccetti Dave Briccetti
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development