【问题标题】:Is there a way to enable referral chasing for UserPrincipal.FindByIdentity()?有没有办法为 UserPrincipal.FindByIdentity() 启用推荐追踪?
【发布时间】:2011-07-31 04:56:47
【问题描述】:

我有一个使用 System.DirectoryServices.AccountManagement 类的 .NET 3.5 Web 应用程序。当我搜索一些用户时,我得到一个 PrincipalOperationException:从服务器返回了一个推荐。如果我使用自己的 LDAP 代码以老式的方式执行此操作,我可以启用对推荐的追逐。我需要重写我的代码吗?

我的代码如下所示:

   using (var principalContext = new PrincipalContext(ContextType.Domain, null, adPath))
    {

        // Find the principal object for which you wish to enumerate group
        // membership.
        using (var userPrincipal = UserPrincipal.FindByIdentity(principalContext, identity))
        {
            if (userPrincipal != null)
            {
                Name = userPrincipal.DisplayName;
                DistinguishedName = userPrincipal.DistinguishedName;
                EmailAddress = userPrincipal.EmailAddress;
                Sid = userPrincipal.Sid.Value;
            }
        }
    }

我的 adPath 可以是 2 个值之一。其中一个值是最近加入的域,可以使用不同的工具进行访问。我相信这是这个 .NET 库如何进行 LDAP 调用的问题。

【问题讨论】:

  • 或许您可以添加更多标签 [.net-3.5]、[windows-server-2008] 或至少 [windows-server]。

标签: c# windows active-directory ldap windows-server


【解决方案1】:

您是否尝试过以下形式的代码(将域作为第二个参数):

var principalContext = new PrincipalContext(ContextType.Domain, "office.local", "OU=Users, DC=office, DC=local" ))

还要确保adPath 从最具体到最不具体。

【讨论】:

    【解决方案2】:

    这是部分答案,因为评论太长了。

    根据this Microsoft documentation,您甚至知道,推荐是客户可以追逐的暗示。但是关于 RODC,他们添加了“例如,在 LDAP 应用程序的情况下,如果在客户端和 RODC 之间的 LDAP 连接上启用了追踪引用,则应用程序永远不会知道客户端收到了来自 RODC 的引用。客户端会自动重定向到引用中指定的可写域控制器。"。

    所以我看看如何在 Microsoft 站点和I found this 的连接上启用 LDAP 追逐,这意味着 ADSI 使用。我对答案很感兴趣。

    您是否尝试这样查询全局目录:

    /* Retreiving a principal context
     */
    PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, "YourGCServer:3268", "dc=dom,dc=fr", "User", "Password");
    

    它应该包含所有林域的数据。 希望对你有帮助。

    【讨论】:

    • 这不是很有帮助。我知道推荐是如何工作的,我需要弄清楚如何使用这个特定的 API 强制推荐。
    猜你喜欢
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多