LDAP: Maximum number of entries returned:

Hi everybody!

We’ve got the following LDAP problem: Setting the LDAP parameter “Maximum number of entries returned” to a value other than 0 (assume n) has the obvious result that you will get at most n search results back. The question is now: How do you get the results not returned in the first page? Using the PagedResultsControl in the search request yields a

javax.naming.OperationNotSupportedException. Following the source code:

package ldapdominotest;

import java.util.*;

import javax.naming.Context;

import javax.naming.directory.InitialDirContext;

import javax.naming.directory.*;

import javax.naming.directory.SearchControls;

import javax.naming.*;

import javax.naming.ldap.InitialLdapContext;

import com.sun.jndi.ldap.ctl.PagedResultsControl;

import com.sun.jndi.ldap.ctl.PagedResultsResponseControl;

public class Test {

public static void main(String args) throws Exception {

final Hashtable env = new Hashtable();

final String FILTER = "(objectclass=*)";



env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://172.17.1.24:389");

// env.put(Context.SECURITY_AUTHENTICATION, “simple”);

// env.put(Context.SECURITY_PRINCIPAL, )

            PagedResultsControl c = new PagedResultsControl(2);

final InitialLdapContext ctx = new InitialLdapContext(env, new PagedResultsControl[]{c});

// final InitialLdapContext ctx = new InitialLdapContext(env, null);

	/*

            ((InitialLdapContext)con).setRequestControls(new Control[] {

                c

            });*/



final SearchControls ctrls = new SearchControls();

ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);

NamingEnumeration results = ctx.search("O=DOLS", FILTER, ctrls);



while ( results != null && results.hasMore() ) {

  final SearchResult res = (SearchResult) results.next();

  final String dn = res.getName();

  System.out.println("dn=" + dn);

  final Attributes attrs = res.getAttributes();

  for ( NamingEnumeration enum = attrs.getAll(); enum.hasMoreElements(); ) {

final Attribute attr = (Attribute) enum.next();

final String attrID = attr.getID();

System.out.println("attrID: " + attrID);

for ( Enumeration enum1 = attr.getAll(); enum1.hasMoreElements(); ) {

  System.out.println("\t " + enum1.nextElement());

}

  }

  System.out.println("\n");

}



System.out.println("OK");

}

}

Subject: LDAP: Maximum number of entries returned:

We’ve got the following LDAP problem: Setting the LDAP parameter “Maximum number of entries returned” to a value other than 0 (assume n) has the obvious result that you will get at most n search results back. The question is now: How do you get the results not returned in the first page? Using the PagedResultsControl in the search request yields a javax.naming.OperationNotSupportedException.

The Domino LDAP server does not support the page/sort controls, which is why you’re getting back that result code from the Domino LDAP server. To ask any LDAP server what controls it supports, your app should issue a “root DSE” search (base is “”, filter is “objectclass=*”) and examine the “supportedControl” attribute.

If you’d like the Domino LDAP server to support page/sort, please let your Lotus contact know! We’re very interested in knowing what our developers need.

To work around this, you can either

set sizelimit to 0

set sizelimit to 0 and partition the universe of possible results into separate queries (e.g., “cn=a*”, “cn=b*”, etc.)

Each has its drawbacks but that’s what’s currently available.