Getting LDAP Response Controls - Java JNDI

Java examples for JNDI:LDAP

Description

Getting LDAP Response Controls

Demo Code

import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.HasControls;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;

public class Main {
  public void m() throws Exception {
    try {//from  ww  w  . ja v  a 2  s.  c o  m
      LdapContext ctx = new InitialLdapContext(null, null);

      // Perform search
      NamingEnumeration answer = ctx.search("ou=People", "(cn=*)", null);

      // Examine the response controls (if any)
      process(ctx.getResponseControls());

      // Enumerate answers
      while (answer.hasMore()) {
        SearchResult si = (SearchResult) answer.next();

        // Examine the response controls (if any)
        if (si instanceof HasControls) {
          process(((HasControls) si).getControls());
        }
      }
      // Examine the response controls (if any)
      process(ctx.getResponseControls());
    } catch (NamingException e) {
    }
  }
  static void process(Object o){
    
  }
}

Related Tutorials