diff --git a/src/main/java/org/lsc/jndi/JndiServices.java b/src/main/java/org/lsc/jndi/JndiServices.java index 083c6e63..f93685d5 100644 --- a/src/main/java/org/lsc/jndi/JndiServices.java +++ b/src/main/java/org/lsc/jndi/JndiServices.java @@ -237,7 +237,7 @@ private void initConnection() throw new NamingException(e.getMessage()); } - // Setting global pageSize variable for LDAPContext + // 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); @@ -246,8 +246,14 @@ private void initConnection() 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()])); + } + String recursiveDeleteStr = (String) ctx.getEnvironment().get("java.naming.recursivedelete"); if (recursiveDeleteStr != null) { recursiveDelete = Boolean.parseBoolean(recursiveDeleteStr);