-+ NamingEnumeration results = dirContext.search(searchBase, searchFilter, constraints);
-+ while (results != null && results.hasMore()) {
-+ SearchResult sr = (SearchResult)results.next();
-+ String username = null;
-+ String home = null;
-+ Attributes attr = sr.getAttributes();
-+ Attribute a = attr.get(homeAttr);
-+ if (a != null && a.size() == 1)
-+ home = (String)a.get();
-+ a = attr.get(userAttr);
-+ if ((home != null) && (a != null)) {
-+ // Add all possible names of this user and corresponding directory
-+ for (int i = 0; i < a.size(); i++) {
-+ username = (String)a.get(i);
-+ if (username != null) {
-+ homes.put(username, home);
++
++ // Request the paged results control
++ if (pageSize > 0) {
++ Control[] ctls = new Control[]{ new PagedResultsControl(pageSize, Control.NONCRITICAL) };
++ ctx.setRequestControls(ctls);
++ }
++
++ byte[] cookie = null;
++ do {
++ NamingEnumeration results = ctx.search(searchBase, searchFilter, constraints);
++ while (results != null && results.hasMore()) {
++ SearchResult sr = (SearchResult)results.next();
++ String username = null;
++ String home = null;
++ Attributes attr = sr.getAttributes();
++ Attribute a = attr.get(homeAttr);
++ if (a != null && a.size() == 1)
++ home = (String)a.get();
++ a = attr.get(userAttr);
++ if ((home != null) && (a != null)) {
++ // Add all possible names of this user and corresponding directory
++ for (int i = 0; i < a.size(); i++) {
++ username = (String)a.get(i);
++ if (username != null) {
++ homes.put(username, home);
++ }