ldap - Java DirContext sreach only few records -
when try search records using query (testatt=1)
in apache directory studio showing me 17062
records , when run same query on java code 8531
records. java code given below
string searchfilter = propfile.getproperty(constants.getallusersquery); string ldapsearchbase = propfile.getproperty(constants.edir_searchbase); searchcontrols searchcontrols = new searchcontrols(); searchcontrols.setsearchscope(searchcontrols.subtree_scope); namingenumeration<searchresult> resultsapp = ctx.search(ldapsearchbase, searchfilter, searchcontrols); int = 0; while (resultsapp.hasmoreelements()) { searchresult result = (searchresult) resultsapp.next(); string dn = ""; dn = result.getnameinnamespace(); if (!dn.isempty()) { edir_allusersdnlist.add(i, dn); i++; } resultsapp.nextelement(); } system.out.println("edir_allusersdnlist : "+edir_allusersdnlist.size());
please me find out issue. using java 8.
while (resultsapp.hasmoreelements()) { searchresult result = (searchresult) resultsapp.next(); string dn = ""; dn = result.getnameinnamespace(); if (!dn.isempty()) { edir_allusersdnlist.add(i, dn); i++; } resultsapp.nextelement(); }
remove final nextelement()
call. doing nothing useful, , skipping even-numbered elements. note 8531 half of 17062.
nb cast redundant, , dn can't empty, , providing initializer when assign on next line pointless.
Comments
Post a Comment