directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neha Rawat <nneharaw...@gmail.com>
Subject Getting a Sorted result by setting SortControl
Date Sun, 09 Nov 2014 16:17:44 GMT
Hi,
I am using apacheds 2.0.0_M17.
I am using javax.naming.ldap.SortControl to get sorted result for a simple
query. Here is some code.

        String sortKey = "cn";
        ctx.setRequestControls(new Control[] { new SortControl(sortKey,
Control.CRITICAL) });
            NamingEnumeration enm =
ctx.search("dc=example,dc=com",  "objectClass=*)", null);



I get this error when i execute it--
Exception in thread "main" javax.naming.CommunicationException: Request: 2
cancelled; remaining name ''
at com.sun.jndi.ldap.LdapRequest.getReplyBer(LdapRequest.java:105)
at com.sun.jndi.ldap.Connection.readReply(Connection.java:447)
at com.sun.jndi.ldap.LdapClient.getSearchReply(LdapClient.java:631)
at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:554)
at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1985)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1847)
at com.sun.jndi.ldap.LdapCtx.getSchemaEntry(LdapCtx.java:1679)
at com.sun.jndi.ldap.LdapCtx.getSchemaTree(LdapCtx.java:1592)
at com.sun.jndi.ldap.LdapCtx.c_getSchema(LdapCtx.java:1539)
at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getSchema(ComponentDirContext.java:433)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getSchema(PartialCompositeDirContext.java:420)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getSchema(PartialCompositeDirContext.java:409)
at
javax.naming.directory.InitialDirContext.getSchema(InitialDirContext.java:206)
at searchEntity.main(searchEntity.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)



When I comment this line -- "ctx.setRequestControls(new Control[] { new
SortControl(sortKey, Control.CRITICAL) });", the query is successful and I
get correct results.

Could you help me understand how to use SortControl? Am I missing something
here?

Thanks






Thanks,
Neha

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message