Referral Chasing with IDirectorySearch

A referral is the mechanism that a directory server uses to direct a client to another server when it does not contain sufficient data about the object requested by a query.

In a one-level or subtree search, referrals are returned for known, immediately subordinate domain, schema, or configuration containers only; that is, child domains that are direct descendants. For more information, see Search Scope.

In a directory, not all data is available on a single server, rather, it is distributed over several different servers across the network. If the servers share the data that other servers can provide, they can provide referrals to a client when a requested query cannot be resolved on the originating server. For example, when a client asks Server A to query a user object (U), then A can suggest that the client continue the search on Server B if U does not reside on A, but is identified to be on B. The client has the choice to pursue the referral or not. Referrals free the client from having to possess previous knowledge of the capability of each server, but the client must specify the type of referrals a server should perform.

To enable or disable referral chasing, set an ADS_SEARCHPREF_CHASE_REFERRALS search option with an ADSTYPE_INTEGER value that contains one of the ADS_CHASE_REFERRALS_ENUM enumeration values in the ADS_SEARCHPREF_INFO array passed to the IDirectorySearch::SetSearchPreference method.

The following code example shows how to enable chase referrals.

ADS_SEARCHPREF_INFO SearchPref;
SearchPref.dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS;
SearchPref.vValue.dwType = ADSTYPE_INTEGER;
SearchPref.vValue.Integer = ADS_CHASE_REFERRALS_ALWAYS;

For more information about referrals in Active Directory, see Referrals.