Announcement Announcement Module
No announcement yet.
Either timing out because too many results - or nothing - now I'm confused! Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Either timing out because too many results - or nothing - now I'm confused!

    Hi, wondering whether someone may be able to help me. I'm really stuck with this ldap library. This is my first time with ldap, and I feel as though I'm just starting to gasp air, after sinking quite rapidly at the beginning. I've now figured out the search syntax, and the attributes supported by ldap. However - I can't get it to work with Spring LDAP.

    I'm instantiating my Spring LDAP classes manually, but I don't think that's what's causing the problem. Here's my code ;-

    DirContextSource context = new DirContextSource ();
    String url = ApplicationResources.getInstance().getProperties() .getProperty("ldap.url");


    LdapTemplate template = new LdapTemplate(context);

    List people ="dc=foo,dc=bar,dc=com","(&(objectc lass=person)(userPrincipalName=" + userId + "*))", new UserContextMapper()); // UserContextMapper as per Sping LDAP example

    If I don't enter a userId, then the search times out, which makes me think that it is actually trying to search, but there are too many users. Then if I specify a userId, nothing is ever returned. I know the Base, and search filter are correct, since I've been using them in a third party tool, without any problems. Can someone please help me shed some light on what's going wrong here. Thanks in advance

  • #2
    First of all you might want to try searching without a base DN, which will eliminate any possible problems with that. In your code example you have two problems with the base path; fortunately they cancel each other out: First you'd need to set the base path before calling afterPropertiesSet. Secondly, specifying the base path as an argument to your search method as well would cause the search to start at the wrong location (dc=foo,dc=bar,dc=com,dc=foo,dc=bar,dc=com rather than just dc=foo,dc=bar,dc=com). Now, since you call afterPropertiesSet before you set base it is effectively not set, which means that you're home free but the above demonstrates some of the problems you might face when you're using base DNs on the contextSource.

    Have you tried narrowing down the search, i.e. specifying userName 'a' (which should return all users with userPrincipalName starting with 'a')? Another theory is that it might be caused by access rights problems. Does the server allow anonymous read only? Some servers don't, and respond by not returning any results at all. Do you get any results with the same exact filter with your third party tool? Could you try hardcoding the search filter so that you have the exact same string, just to be sure?