J
John Gordon
I'm writing a program to query an LDAP server and obtain a list of users.
The list can be quite large, so I need a way to request the results of
the search be returned in small chunks. Luckily, the server I will be
using supports the VirtualListViewControl class, which does just that.
(The server does not support PagedResultsControl.)
However, I cannot get it to work. The following code fragment without
a VirtualListViewControl works correctly:
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldaps://myserver.com:636");
env.put(Context.SECURITY_PRINCIPAL, "cn=Fred Smith");
env.put(Context.SECURITY_CREDENTIALS, "sekrit");
LdapContext ctx = new InitialLdapContext(env, null);
SearchControls ctrl = new SearchControls();
ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration<SearchResult> request = ctx.search("","username=joe",ctrl);
However, if I add a VirtualListViewControl before the ctx.search() call, I
get an error:
Control[] ctxControls = new Control[]
{new VirtualListViewControl(0, 10, 0, 9, Control.CRITICAL)};
ctx.setRequestControls(ctxControls);
The error I get is javax.naming.NamingException: [LDAP: error code 60 - VLV Control]; remaining name ''
I've tried numerous web searches, but there don't seem to be many practical
examples of using a VirtualListViewControl.
Anyone have any advice?
The list can be quite large, so I need a way to request the results of
the search be returned in small chunks. Luckily, the server I will be
using supports the VirtualListViewControl class, which does just that.
(The server does not support PagedResultsControl.)
However, I cannot get it to work. The following code fragment without
a VirtualListViewControl works correctly:
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldaps://myserver.com:636");
env.put(Context.SECURITY_PRINCIPAL, "cn=Fred Smith");
env.put(Context.SECURITY_CREDENTIALS, "sekrit");
LdapContext ctx = new InitialLdapContext(env, null);
SearchControls ctrl = new SearchControls();
ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration<SearchResult> request = ctx.search("","username=joe",ctrl);
However, if I add a VirtualListViewControl before the ctx.search() call, I
get an error:
Control[] ctxControls = new Control[]
{new VirtualListViewControl(0, 10, 0, 9, Control.CRITICAL)};
ctx.setRequestControls(ctxControls);
The error I get is javax.naming.NamingException: [LDAP: error code 60 - VLV Control]; remaining name ''
I've tried numerous web searches, but there don't seem to be many practical
examples of using a VirtualListViewControl.
Anyone have any advice?