Announcement Announcement Module
Collapse
No announcement yet.
OperationNotSupportedException when trying to sort by last name Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OperationNotSupportedException when trying to sort by last name

    I am using the person demo sample project from the spring ldap 1.3.0.RELEASE. While trying to test the method to search for all persons
    sorted by last name, I am getting an OperationNotSupportedException. Any help is appreciated.

    The method to retrieve all persons sorted by last name is as follows:
    Code:
    public List findAllSortedByLastName() {
    		SortControlDirContextProcessor sortControl = new SortControlDirContextProcessor("sn");
    		AggregateDirContextProcessor processor = new AggregateDirContextProcessor();	
    		processor.addDirContextProcessor(sortControl);
    		SearchControls searchControls = new SearchControls();
    		searchControls.setReturningObjFlag(true);
    		searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    		return ldapTemplate.search("", "(objectclass=person)", searchControls , new PersonContextMapper(), processor);
    	}
    The PersonContextMapper instance is the same as the one provided in the sample. Including that as well:
    Code:
    	private static class PersonContextMapper extends AbstractContextMapper {
    
    		public Object doMapFromContext(DirContextOperations ctx) {
    			DirContextAdapter context = (DirContextAdapter) ctx;
    			Person person = new Person();
    			person.setFullName(context.getStringAttribute("cn"));
    			person.setLastName(context.getStringAttribute("sn"));
    			person.setDescription(context.getStringAttribute("description"));
    			person.setPhone(context.getStringAttribute("telephoneNumber"));
    
    			DistinguishedName dn = (DistinguishedName) context.getDn();
    			person.setCountry(dn.getValue("c"));
    			person.setCompany(dn.getValue("ou"));
    			return person;
    		}
    }
    The trace follows:

    Code:
    org.springframework.ldap.OperationNotSupportedException: [LDAP: error code 12 - Unsupport critical control: 1.2.840.113556.1.4.473]; nested exception is javax.naming.OperationNotSupportedException: [LDAP: error code 12 - Unsupport critical control: 1.2.840.113556.1.4.473]; remaining name ''
    	at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:199)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:319)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:259)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:606)
    	at org.springframework.ldap.demo.solution.PersonDaoImpl.findAllSortedByLastName(PersonDaoImpl.java:55)
    	at org.springframework.ldap.demo.dao.PersonDaoIntegrationTest.testFindAllSortedByLastName(PersonDaoIntegrationTest.java:157)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	at junit.framework.TestCase.runTest(TestCase.java:168)
    	at junit.framework.TestCase.runBare(TestCase.java:134)
    	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
    	at junit.framework.TestResult$1.protect(TestResult.java:110)
    	at junit.framework.TestResult.runProtected(TestResult.java:128)
    	at junit.framework.TestResult.run(TestResult.java:113)
    	at junit.framework.TestCase.run(TestCase.java:124)
    	at junit.framework.TestSuite.runTest(TestSuite.java:232)
    	at junit.framework.TestSuite.run(TestSuite.java:227)
    	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: javax.naming.OperationNotSupportedException: [LDAP: error code 12 - Unsupport critical control: 1.2.840.113556.1.4.473]; remaining name ''
    	at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3131)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3017)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2823)
    	at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1832)
    	at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1755)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321)
    	at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248)
    	at org.springframework.ldap.core.LdapTemplate$4.executeSearch(LdapTemplate.java:253)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:293)
    	... 24 more

  • #2
    What LDAP server are you using?

    Not all LDAP servers support sorting control. Looking at your exception "Unsupport critical control: 1.2.840.113556.1.4.473", it looks like your LDAP server does not support it.

    You can query your LDAP server to get a list of supported controls. I use the ldapserch tool that comes with OpenDS (https://www.opends.org/wiki/page/Ldapsearch) to do the query:

    $ ldapsearch -h hostname -p 1389 -b "" -s base "(objectclass=*)" supportedControl

    dn:
    supportedControl: 1.2.826.0.1.3344810.2.3
    supportedControl: 1.2.840.113556.1.4.319
    supportedControl: 1.2.840.113556.1.4.473
    supportedControl: 1.2.840.113556.1.4.805

    Comment


    • #3
      I am using the LDAP server that comes with the spring-ldap-test-1.3.0.release jar. Looking at the project's pom it looks like the apacheds server v1.0.2.

      These are the supported controls and it doesn't look like server side sorting is supported.
      1.3.6.1.4.1.4203.1.10.1 (Subentries)
      2.16.840.1.113730.3.4.2 (ManageDsaIT)
      2.16.840.1.113730.3.4.3 (Persistent Search)
      2.16.840.1.113730.3.4.7 (Entry Change Notification)

      Your response is very helpful as the target LDAP server I am going to use definitely supports server side sorting and a lot of other useful supportedControls, now that I know to look at the attributes on the Root DSE to figure that out.

      Thanks!

      Comment

      Working...
      X