Announcement Announcement Module
Collapse
No announcement yet.
Searching from a given point and down Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Searching from a given point and down

    I'm getting some odd behaviour when I try and search only from a given point in the tree.

    I'm calling the code like this:

    Code:
    ldapTemplate.search(groupRoot, activeMemberFilter, uniqueNamesMapper);
    groupRoot looks like:
    Code:
    ou=SectionName,ou=GroupName,dc=domain,dc=tld
    activeMemberFilter looks like:
    Code:
    (&(uniqueMember=*)(!(|(cn=Exclude1)(cn=Exclude2)(cn=Exclude3))))
    When I do this - I get no results whatsoever.

    But - I can run the command line search

    Code:
    ldapsearch -b 'ou=SectionName,ou=GroupName,dc=domain,dc=tld' '(&(uniqueMember=*)(!(|(cn=Exclude1)(cn=Exclude2)(cn=Exclude3))))'
    and I get the correct results.

    If I call it like this:

    Code:
    ldapTemplate.search("", activeMemberFilter, uniqueNamesMapper);
    Then the search returns - gives me all the info I require and more (in other words - it returns the data from the whole tree - including the sub-tree I'm trying to search).

    I've tried debugging. I get to the method in LdapTemplate

    Code:
    public void search(SearchExecutor se, NameClassPairCallbackHandler handler);
    This has a try/catch/finally block. When the groupRoot is specified - then as soon as you call the se.executeSearch(ctx) flow goes to the finally block (no exception is caught) - it doesn't even hit the while() loop to see if there are any results.

    I just can't see what I'm doing wrong I've tried some other simpler searches - any search where the base is not "" returns the empty set - any search where base is "" returns what I expect.

    This is spring-ldap 1.1 retrieved via maven.

    I could really do with some hints as to what I'm doing wrong here.

  • #2
    Have you supplied any base path in the ContextSource setup? In that case that path will be added to the one you supply as base in the search, i.e. if your ContextSource base is:
    Code:
    dc=domain,dc=tld
    and the search base is
    Code:
    ou=SectionName,ou=GroupName,dc=domain,dc=tld
    the actual base for your search will be
    Code:
    ou=SectionName,ou=GroupName,dc=domain,dc=tld,dc=domain,dc=tld
    That search base would likely not exist, which would cause an exception being thrown from the JNDI search method. This exception is deliberately ignored by LdapTemplate, as it indicates that no entries are found, which would cause you to end up in the finally block right away.

    BTW, you should upgrade; the current production release is 1.1.2, and that is available in maven repo too.

    Comment


    • #3
      Originally posted by rasky View Post
      Have you supplied any base path in the ContextSource setup? In that case that path will be added to the one you supply as base in the search, i.e. if your ContextSource base is:
      Code:
      dc=domain,dc=tld
      and the search base is
      Code:
      ou=SectionName,ou=GroupName,dc=domain,dc=tld
      the actual base for your search will be
      Code:
      ou=SectionName,ou=GroupName,dc=domain,dc=tld,dc=domain,dc=tld
      Bingo! And so obvious too Thanks for a very fast answer - I started converting a non-spring app today - and this was as far as I got

      Originally posted by rasky View Post
      BTW, you should upgrade; the current production release is 1.1.2, and that is available in maven repo too.
      Hmm - I will dig deeper. I am currently (again - as of a few hours ago) using the maven eclipse extension - and when I search for spring - under org.springframework spring-ldap I see only 1.1 - spring-ldap-1.1.jar - 75421 - Fri Oct 13 15:32:00 CEST 2006 [central]

      Comment


      • #4
        rasky, thanks for that explanation. I have this problem also. Now I understand the library and its configuration a little better.

        Comment

        Working...
        X