diff --git a/src/main/java/org/lsc/jndi/JndiServices.java b/src/main/java/org/lsc/jndi/JndiServices.java index c8f94e86..110f8304 100644 --- a/src/main/java/org/lsc/jndi/JndiServices.java +++ b/src/main/java/org/lsc/jndi/JndiServices.java @@ -1205,23 +1205,20 @@ public byte[] pagination() throws IOException, NamingException { * Applying request controls such as pageSize and sortedBy for LDAP Context. */ public void contextRequestControls() { + List requestControls = new ArrayList<>(); try { // Setting global pageSize variable String pageSizeStr = (String) ctx.getEnvironment().get("java.naming.ldap.pageSize"); if (pageSizeStr != null && Integer.parseInt(pageSizeStr) > -1) { pageSize = Integer.parseInt(pageSizeStr); - List requestControls = new ArrayList<>(); requestControls.add(new PagedResultsControl(pageSize, Control.CRITICAL)); - ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } - // Setting global sortedBy variable sortedBy = (String) ctx.getEnvironment().get("java.naming.ldap.sortedBy"); if (sortedBy != null) { - List requestControls = new ArrayList<>(); requestControls.add(new SortControl(sortedBy, Control.CRITICAL)); - ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } + ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()])); } catch (NamingException | IOException e) { throw new RuntimeException(e); }