Directory Services

Additional Search Options

DirectorySearcher contains additional search options that you can add to an application to retrieve the best possible result set.

If the search does not yield results on the default server, then the server can return a referral for another server for the client to search. If referral chasing is set to All, then the client will query the server named in the referral. If set to None, then the client will not chase referrals. To set referral chasing, use the ReferralChasing property. The flags that can be used for ReferralChasing can be found in the ReferralChasingOption enumeration. The following code examples show how to set this property.

[Visual Basic .NET]
Dim entry As New DirectoryEntry("LDAP://CN=computers,DC=buffalo,DC=corp,DC=fabrikam,DC=com")
Dim mySearcher As New DirectorySearcher(entry)
mySearcher.ReferralChasing = ReferralChasingOption.All
' Handle results.
' Handle errors.
[C#]
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=computers,DC=buffalo,DC=corp,DC=fabrikam,DC=com");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.ReferralChasing = ReferralChasingOption.All;
// Handle results.
// Handle errors.