Skip to content

Commit

Permalink
lsc-project#176: Improving contextRequestControls
Browse files Browse the repository at this point in the history
  • Loading branch information
abpai94 committed Nov 12, 2024
1 parent 00c6653 commit 3308b20
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/org/lsc/jndi/JndiServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<BasicControl> 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<PagedResultsControl> 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<SortControl> 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);
}
Expand Down

0 comments on commit 3308b20

Please sign in to comment.