Referrals

An LDAP server can include a referral result code for most operations. The most common use case for referrals is for searching. If you wish to follow referrals, Ldaptive provides an implementation called FollowSearchReferralHandler for this purpose. If no referral handler is provided and a referral result code is received, the referral URL(s) can be inspected on the response with getReferralURLs().

SearchOperation search = new SearchOperation(new DefaultConnectionFactory("ldap://directory.ldaptive.org"));
search.setSearchResultHandlers(new FollowSearchReferralHandler());
SearchResponse res = search.execute(SearchRequest.builder()
  .dn("dc=ldaptive,dc=org")
  .filter("(&(givenName=daniel)(sn=fisher))")
  .build());
LdapEntry entry = res.getEntry(); // if you're expecting a single entry
for (LdapEntry le : res.getEntries()) { // if you're expecting multiple entries
  // do something useful with the entry
}