searchControls.setCountLimit(5);
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
Control[] requestControls =
{new PagedResultsControl(3, Control.CRITICAL), new SortControl(new String[]{"cn"}, Control.NONCRITICAL)};
ctx.setRequestControls(requestControls);
results = ctx.search(DEVELOPER_UNIT_DN, "(objectclass=person)", searchControls);
while (results.hasMoreElements())
{
SearchResult sr = (SearchResult)results.nextElement();
printAttributes(sr.getName(), sr.getAttributes());
if (sr instanceof HasControls)