Directory ApacheDS
  1. Directory ApacheDS
  2. DIRSERVER-1061

Search fails with unrecognized attribute in boolean filters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.2, 1.5.1
    • Fix Version/s: 1.5.2
    • Component/s: core
    • Labels:
      None
    • Environment:
      ApacheDS 1.0.2 on Windows Server 2003 SP2 and Apache DS 1.5.1 on Mac OS X 10.4.10.

      Description

      If I search for "(unknown=)" I correctly get no results. But if I search for "(&(unknown=))" I get:

      Caused by: javax.naming.NamingExc
      eption: OID for name 'unknown' was not found within the OID registry
      at org
      .apache.directory.server.schema.registries.DefaultOidRegistry.getOid(Default
      OidRegistry.java:113)
      at org.apache.directory.server.core.normalization.Nor
      malizingVisitor.visit(NormalizingVisitor.java:88)
      ... 25 more

      Other variations of boolean operators also fail, such as "(|(uid=)(unknown=))" where "(uid=*)" by itself yields results.

      According to RFC 4511 section 4.5.1, servers MUST NOT return errors in this situation.

      I found similar bugs, such as DIRSERVER-645 and DIRSERVER-836, but nothing covering this exact situation.

      The error is not specific to ldapsearch; I actually found the error using another application, and I was simply testing with something simpler and more widely available. I filed this as minor, because in most cases you can obviously avoid using an invalid attribute, but it's actually worse than that. The original application can't be modified, for example, and I can't use Apache DS as the LDAP server with it because the exception causes the LDAP autoconfiguration to fail.

      The full ldapsearch command line and output:

      $ ldapsearch -x -H ldap://localhost:10389 -D 'uid=admin,ou=system' -w **** -b 'ou=system' -s sub '(&(unknown=*))' uid

      1. extended LDIF
        #
      2. LDAPv3
      3. base <ou=system> with scope sub
      4. filter: (&(unknown=*))
      5. requesting: uid
        #
      1. search result
        search: 2
        result: 36 Alias dereferencing problem
        text: failed on search operation: Unexpected exception.:
        SearchRequest

      baseDn : 'ou=system'
      filter : '(& (unknown=*) ) '
      scop
      e : whole subtree
      typesOnly : false
      no limit
      Time Limit : no
      limit
      Deref Aliases : never Deref Aliases
      attributes : 'uid
      '
      :
      org.apache.directory.server.core.interceptor.InterceptorException: Unexp
      ected exception. [Root exception is java.lang.RuntimeException: OID for name
      'unknown' was not found within the OID registry]
      at org.apache.directory.s
      erver.core.interceptor.InterceptorChain.throwInterceptorException(Intercepto
      rChain.java:1472)
      at org.apache.directory.server.core.interceptor.Intercept
      orChain.search(InterceptorChain.java:888)
      at org.apache.directory.server.co
      re.partition.PartitionNexusProxy.search(PartitionNexusProxy.java:492)
      at or
      g.apache.directory.server.core.partition.PartitionNexusProxy.search(Partitio
      nNexusProxy.java:434)
      at org.apache.directory.server.core.jndi.ServerContex
      t.doSearchOperation(ServerContext.java:249)
      at org.apache.directory.server.
      core.jndi.ServerDirContext.search(ServerDirContext.java:642)
      at org.apache.
      directory.server.ldap.support.SearchHandler.messageReceived(SearchHandler.ja
      va:376)
      at org.apache.mina.handler.demux.DemuxingIoHandler.messageReceived(
      DemuxingIoHandler.java:141)
      at org.apache.directory.server.ldap.LdapProtoco
      lProvider$LdapProtocolHandler.messageReceived(LdapProtocolProvider.java:428)
      at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.message
      Received(AbstractIoFilterChain.java:570)
      at org.apache.mina.common.support.
      AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299
      )
      at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(Abstr
      actIoFilterChain.java:53)
      at org.apache.mina.common.support.AbstractIoFilte
      rChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
      at org.a
      pache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProt
      ocolDecoderOutput.java:58)
      at org.apache.mina.filter.codec.ProtocolCodecFil
      ter.messageReceived(ProtocolCodecFilter.java:176)
      at org.apache.mina.common
      .support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain
      .java:299)
      at org.apache.mina.common.support.AbstractIoFilterChain.access$1
      100(AbstractIoFilterChain.java:53)
      at org.apache.mina.common.support.Abstra
      ctIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)

      at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilt
      er.java:220)
      at org.apache.mina.filter.executor.ExecutorFilter$ProcessEvent
      sRunnable.run(ExecutorFilter.java:264)
      at java.util.concurrent.ThreadPoolEx
      ecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.
      ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thr
      ead.run(Thread.java:613)
      Caused by: java.lang.RuntimeException: OID for name
      'unknown' was not found within the OID registry
      at org.apache.directory.se
      rver.core.normalization.NormalizingVisitor.visit(NormalizingVisitor.java:93)
      at org.apache.directory.shared.ldap.filter.PresenceNode.accept(PresenceNod
      e.java:97)
      at org.apache.directory.shared.ldap.filter.BranchNode.accept(Bra
      nchNode.java:408)
      at org.apache.directory.server.core.normalization.Normali
      zationService.search(NormalizationService.java:210)
      at org.apache.directory
      .server.core.interceptor.InterceptorChain.search(InterceptorChain.java:880)

      ... 21 more
      Caused by: javax.naming.NamingException: OID for name 'unknown'
      was not found within the OID registry
      at org.apache.directory.server.schem
      a.registries.DefaultOidRegistry.getOid(DefaultOidRegistry.java:113)
      at org.
      apache.directory.server.core.normalization.NormalizingVisitor.visit(Normaliz
      ingVisitor.java:88)
      ... 25 more

      1. numResponses: 1

        Issue Links

          Activity

          Hide
          Emmanuel Lecharny added a comment -

          closed

          Show
          Emmanuel Lecharny added a comment - closed
          Hide
          Emmanuel Lecharny added a comment -

          Fixed in Trunk.

          The idea was to change the way filters are handled (they are now handled in the LeafEvaluator, instead of into the NormalizationService. We don't create anymore this ugly OR with all the descendants ...).

          No more exception is thrown when an unkown attribute is found in the filter. If it's an AND operation, you get no result. If it's an O, you get the result found with the filter without the problematic attribute.

          Show
          Emmanuel Lecharny added a comment - Fixed in Trunk. The idea was to change the way filters are handled (they are now handled in the LeafEvaluator, instead of into the NormalizationService. We don't create anymore this ugly OR with all the descendants ...). No more exception is thrown when an unkown attribute is found in the filter. If it's an AND operation, you get no result. If it's an O, you get the result found with the filter without the problematic attribute.
          Hide
          Ersin Er added a comment -

          DIRSERVER-971 is about a general solution to this problem. Although it does not state the solution, it talks about predefined filter nodes for True, False and Undefined.

          Show
          Ersin Er added a comment - DIRSERVER-971 is about a general solution to this problem. Although it does not state the solution, it talks about predefined filter nodes for True, False and Undefined.
          Hide
          Ersin Er added a comment -

          I dropped an issue on this about three months ago. I had not specified a certain problem but I thought we need to observe server's behavior.

          https://issues.apache.org/jira/browse/DIRSERVER-972

          Show
          Ersin Er added a comment - I dropped an issue on this about three months ago. I had not specified a certain problem but I thought we need to observe server's behavior. https://issues.apache.org/jira/browse/DIRSERVER-972
          Hide
          Emmanuel Lecharny added a comment -

          the NormalizingVisitor.visit( ExprNode ) method throws an exception when the attribute ID does not exist in the registry.

          If the caller gets an exception, then it should simply discard the element. It can be a pb as the filter tree will have to be reorganized at some point :
          (& (objectclass = *) ( unknown = * ) ) will become (& (objectclass = * ) ), when the '&' operation request two values. A new DAG will have to be created.

          Not an easy fix ...

          Show
          Emmanuel Lecharny added a comment - the NormalizingVisitor.visit( ExprNode ) method throws an exception when the attribute ID does not exist in the registry. If the caller gets an exception, then it should simply discard the element. It can be a pb as the filter tree will have to be reorganized at some point : (& (objectclass = *) ( unknown = * ) ) will become (& (objectclass = * ) ), when the '&' operation request two values. A new DAG will have to be created. Not an easy fix ...
          Hide
          Emmanuel Lecharny added a comment -

          Raised to major, as we are breaking the specs.

          Show
          Emmanuel Lecharny added a comment - Raised to major, as we are breaking the specs.
          Hide
          Emmanuel Lecharny added a comment -

          I confirm that this is a bug. Tested on 1.5.1 server with Apache Directory Studio.

          Thanks for the report John !

          Show
          Emmanuel Lecharny added a comment - I confirm that this is a bug. Tested on 1.5.1 server with Apache Directory Studio. Thanks for the report John !

            People

            • Assignee:
              Unassigned
              Reporter:
              John Lacey
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development