Intermittent summarization errors with DirectorySearcher

I am using DirectorySearcher

to find user accounts based on email addresses:

using (var searcher = new DirectorySearcher
{
    SearchRoot = new DirectoryEntry($"LDAP://DC={companyOfficeLocation},DC={companyDomain},DC=com"),
    SearchScope = SearchScope.Subtree,
    Filter = $"(mail={email})",
    PropertiesToLoad = { "sAMAccountName" },
    ReferralChasing = ReferralChasingOption.All,
})
{
    return searcher.FindAll().Cast<SearchResult>()
        .Select(r => (string)r.Properties["sAMAccountName"][0])
        .ToList();
}

      

This code is interrupted with System.DirectoryServices.DirectoryServicesCOMException

an error message A referral was returned from the server.

.

These errors are inconsistent between machines (for example, on different web servers, the same request may fail or succeed in the same timeframe). There are some indications that restarting the Active Directory server or restarting the web server may cause errors.

I'm wondering: what are the possible causes of referral errors? Why do I see referral errors even though the property ReferralChasing

matters All

?

EDIT:

A bit more information from the property ExtendedErrorMessage

DirectoryServicesCOMException

:

0000202B: RefErr: DSID-031007F3, data 0, 1 access point ref 1: 'arlington.predictivetechnologies.com'

+3


source to share





All Articles