I have now tried to make this work for two days with two different libraries, but it just don’t want to do what I want. So here’s the problem:
I’m trying to load ldap entries with java, I’m using the “org.ietf.ldap”-Library.
Without problems, I can get single entries out of ldap, works perfectly, but with a special query, I only get one entry back from ldap, but there should be 15 entries.
Here’s my code:
public void getEntries (String searchDN, int scope, InitialDirContext conn, String attributeName, String attributeValue) { List ansp = new ArrayList(); final String QUERY = "cpMemDN=cn=usuid,ou=EMP,ou=COMPANY,o=META"; searchDN = "ou=SUPPORT, ou=ROLES, ou=SERVICES, ou=COMPANY, o=META"; SearchControls ctrl = new SearchControls(); ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); NamingEnumeration enumeration = null;try { enumeration = context.search(searchDN, QUERY, ctrl); } catch (NamingException e) { e.printStackTrace(); } Set<String> cns = new HashSet<String>(); try { while (enumeration.hasMore()) { SearchResult result = (SearchResult) enumeration.next(); } } catch (NamingException e) { e.printStackTrace(); } }
So how I said, the enumeration only contains one entry instead of 15 entries (checked with LDAPBrowser). I also tried getting multiple entries with another query (cn=*) and it worked, I got multiple entries but the query can't be the problem because it works with LDAPBrowser.Any ideas?
Okey it works now with the same code, just tried for 50 times haha. Strange thing, but solved.