Menu

Help with encoding issue

Adam
2014-05-12
2014-05-12
  • Adam

    Adam - 2014-05-12

    Hello,

    I'm trying to do a fairly straightforward query and when I create a search
    using my query string directly it works fine but when I pass in a filter
    generated using the Filter.create* methods it returns nothing.

    Here is the query I'm trying to generate:

    (&(objectCategory=computer)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))

    So as I've stated if I pass that as a string when creating a SearchRequest
    then it correctly returns all computers that are not disabled. However,
    when I generate the filter like this:

    Filter.createANDFilter(
      Filter.createEqualityFilter("objectCategory", "computer"),
      Filter.createNOTFilter(
    

    Filter.createEqualityFilter("userAccountControl:1.2.840.113556.1.4.803:",
    "2")))

    it returns nothing. The strange thing is that calling either toString() or
    even toNormalizedString() returns the same string. However, when I call
    the encode method on the generated str vs one created with
    Filter.create(str) then the valueBytes are completely different! Can
    somebody help me understand what's going on here?

    ~Adam~

     
  • Neil Wilson

    Neil Wilson - 2014-05-12

    The problem is that "(userAccountControl:1.2.840.113556.1.4.803:=2)" is not an equality filter. It is an extensible match filter with an attribute type of "userAccountControl", a matching rule ID of "1.2.840.113556.1.4.803", and an assertion value of "2". Rather than using:

     Filter.createEqualityFilter(
          "userAccountControl:1.2.840.113556.1.4.803:",
          "2")
    

    You should use:

     Filter.createExtensibleMatchFilter(
          "userAccountControl",
          "1.2.840.113556.1.4.803",
          false,
          "2")
    

    Neil

     

Log in to post a comment.