0

I am using this LDAP class in my app. I have Apache DS at my localhost and it works correctly.

In my app I'm successfully connected to LDAP server:

  conn.connect("localhost", 10389);
  conn.bind(LDAPConnection.LDAP_V3, "uid=admin,ou=system","secret".getBytes("UTF8"));

Then Im trying to search some data in LDAP catalog:

  attrList = new String[]{"dn", "cn", "mail"};
  sFilter = "(mail=admin@test.com)";

  LDAPSearchConstraints cons = new LDAPSearchConstraints();
  cons.setDereference(LDAPSearchConstraints.DEREF_ALWAYS);
  LDAPSearchResults searchResults = conn.search("uid=admin,ou=system", LDAPConnection.SCOPE_SUB, sFilter, attrList, false,cons);

And there is no results in searchResults. So can you help me? But when i user search with SAME PARAMETERS in Apache DS Studio I can see some results. Please check this screenshot.

Java Dude
  • 454
  • 6
  • 24
  • In the screen shot, the filter is different, as is the list of requested attributes. Is that by design? – Terry Gardner Nov 22 '13 at 12:21
  • Its just my stupid mistake. Screenshot is fixed now. – Java Dude Nov 22 '13 at 12:34
  • Are objects with the `mail` attribute subordinate to `uid=admin,ou=system`? With the base object set to that value, the LDAP directory server will only consider objects at or below the base object as candidates to return to the LDAP client in the search result. – Terry Gardner Nov 22 '13 at 12:56

1 Answers1

0

I use code like this:

Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasiAttribute("mail", "admin@test.com"));
NamingEnumeration<SearchResult> answer = ctx.search(context, matchAttrs);

Where ctx is of type InitialDirContext, and context is the search root (a context).

RokL
  • 2,663
  • 3
  • 22
  • 26
  • Thanks, but i am using norvell implementation of LDAP. The root of the issue - incorrect catalog LDAP config – Java Dude Nov 29 '13 at 11:16