![]() ![]() ![]() ![]() |
Referrals |
If you set the Context.REFERRAL(java.naming.referral) environment property to "ignore", then any referral entries in the directory will be ignored and returned as plain entries. The LDAP provider will automatically send a "manage referral" control with the request for LDAP v3, telling the LDAP server to return the referral entries as plain LDAP entries. If the LDAP v2 is being used, no control is sent.
Here's an example:
// Set referral property; optionally because "ignore" is the default env.put(Context.REFERRAL, "ignore"); // Create initial context DirContext ctx = new InitialDirContext(env); // Set controls for performing subtree search SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); // Perform search NamingEnumeration answer = ctx.search("", "(objectclass=*)", ctls);If you run this example, it produces the following results:
Note: If you're using 1.0.1 of the LDAP provider, you need to add the following line before creating the initial context:// Set managed referral env.put("java.naming.ldap.control.manageReferral", "true");
>>> >>>ou=People >>>ou=All >>>ou=People, ou=All >>>ou=NewHires, ou=AllNotice that the entries "ou=People", "ou=People, ou=All", and "ou=NewHires, ou=All" are returned as plain entries rather than referrals.
![]() ![]() ![]() ![]() |
Referrals |