3

DirectorySearcher用来根据电子邮件地址查找用户帐户:

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();
}

此代码间歇性地失败并System.DirectoryServices.DirectoryServicesCOMException显示错误消息A referral was returned from the server.

这些错误在机器之间并不一致(例如,在不同的 Web 服务器上,相同的查询可能在相同的时间范围内失败或成功)。有一些迹象表明 ActiveDirectory 服务器重新启动或 Web 服务器重新启动可能会触发错误。

我想知道:推荐错误的可能原因是什么?ReferralChasing尽管将属性设置为 ,为什么我会看到推荐错误All

编辑:

ExtendedErrorMessage从 的属性中捕获的更多信息DirectoryServicesCOMException

0000202B:RefErr:DSID-031007F3,数据 0、1 个接入点参考 1:“arlington.predictivetechnologies.com”

4

0 回答 0