You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Juan Carlos Marin Rincon <jm...@gmail.com> on 2016/04/15 21:59:02 UTC

LDAP API search cursor returns diferent number of values

Hi all,

I´m try to run a search into Tivoli Directory Server, the query is:
(&(objectClass=gruopOfUniqueNames)(uniquemember=<entry_dn>)). If I run that
query in Apache Directory Studio i get 43 entries, but when I try to run
that query in a Java program, never get the 43 entries, sometimes get 40,
sometimes 38, 35, 20, 25, 29... entries, but never the 43 entries. I'm
using api-all-1.0.0-M20, I try with version M33 too, but I got the same
result, sometimes i got entries, sometimes not, but never i got all
results. This issue is urgent because affects PRODUCTION environment.
Thanks for any help.

My Code:

EntryCursor cursor = null;
LdapConnection conn = null;
String query =
"(&(objectClass=groupOfUniqueNames)(uniquemember=<user_dn>))";
try {
    LdapConnectionConfig config = new LdapConnectionConfig();
    config.setLdapHost(<server_ip>);
    config.setLdapPort(<port>);
    config.setName(<user>);
    config.setCredentials(<password>);

    for (int i = 0; i < 10; i++) {
        conn = new LdapNetworkConnection(config);
        conn.bind();

        cursor = conn.search("<base_path>", query, SearchScope.SUBTREE);

        List<Entry> result = new ArrayList<Entry>();

        while (cursor.next()) {
            result.add(cursor.get());
        }

        System.out.println("ENTRIES IT " + i + " : " + result.size());

        try {
            if (cursor != null) {
                cursor.close();
            }

            if (conn != null) {
                conn.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} catch (LdapException e) {
    e.printStackTrace();
} catch (CursorException e) {
    e.printStackTrace();
}


Results:

ENTRIES IT 0 : 0
ENTRIES IT 1 : 40
ENTRIES IT 2 : 20
ENTRIES IT 3 : 0
ENTRIES IT 4 : 0
ENTRIES IT 5 : 40
ENTRIES IT 6 : 0
ENTRIES IT 7 : 33
ENTRIES IT 8 : 0
ENTRIES IT 9 : 26

Juan Carlos Marín Rincón
Software Architect

Re: LDAP API search cursor returns diferent number of values

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 15/04/16 21:59, Juan Carlos Marin Rincon a écrit :
> Hi all,
>
> I´m try to run a search into Tivoli Directory Server, the query is:
> (&(objectClass=gruopOfUniqueNames)(uniquemember=<entry_dn>)). If I run that
> query in Apache Directory Studio i get 43 entries, but when I try to run
> that query in a Java program, never get the 43 entries, sometimes get 40,
> sometimes 38, 35, 20, 25, 29... entries, but never the 43 entries. I'm
> using api-all-1.0.0-M20, 
First of all, have you tried with api-all-M33 ? M20 is 3 years old, and
tens of bugs have been fixed since then.