javax.naming.ldap.ManageReferralControl
The Sun LDAP service provider will send this control automatically along with any request. You can also explicitly enable it setting Context.REFERRAL environment property to "ignore". For more information on Referral handling check the Referrals in the JNDI section of the JNDI Tutorial.
Here is an example that sends Manage Referral control along with an
LDAP request.
// Create initial context
LdapContext ctx = (LdapContext) new InitialDirContext(env);
ctx.setRequestControl(new Control[] new ManageReferralControl());
// Set controls for performing subtree search
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// Perform search
NamingEnumeration answer = ctx.search("", "(objectclass=*)", ctls);
// Print the answer
while (answer.hasMore()) {
System.out.println(">>>" + ((SearchResult)answer.next()).getName());
}
// Close the context when we're done
ctx.close();
Setting up a directory server is typically performed by the directory or system administrator. See the Software Setup lesson for more information.
Note 2: Windows Active Directory: Because Active Directory does not support the Manage Referral control, none of the examples in this lesson will work against Active Directory.