【问题标题】:Cross domain active directory group membership跨域活动目录组成员资格
【发布时间】:2012-03-02 13:12:05
【问题描述】:

我看到了一些与我类似的问题,但没有一个真正适用。我面临的问题是:

我需要通过以下方式获得用户的组成员身份:

  • 域 B 中的组
  • 域 A 中的用户。
  • 域 B 中的服务。
  • Forrest 到 Forrest 2 向信任。

用户附加到服务和服务获取带有 SID、名称等的 WindowsIdentity 对象。

为了获得组成员资格,我使用了一个 UserPrincipal 对象。为了得到它,你需要一个 PrincipalContext 对象。 PrincipalContext 对象的构造函数需要域的 FQDN(即 A.some.domain.com)。 WindowsIdentity 对象在用户名中有 NetBios 域名(即 A\User),但我看不到获取 DNS 名称的方法。

这是一个具有 DNS 名称 HARD CODED 的代码示例,它有效,但我需要取出硬编码部分。

-- WindowsIdentity wi(传入方法)--

PrincipalContext context = new PrincipalContext(ContextType.Domain, "A.some.domain.com");
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.Sid, wi.User.ToString());

我有另一个使用模拟的解决方案,使用 System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name,但这是不可接受的,因为模拟可能不可用。我需要一个适用于 TokenImpersonationLevel.Identification

的解决方案

我花了几天时间搜索 MSDN 和 Google(包括 Stack Overflow),但无济于事。

【问题讨论】:

    标签: c# .net active-directory dns netbios


    【解决方案1】:

    使用WindowsIdentity.Groups 不起作用吗?如果 DomainA\User 正在访问 DomainB\Service,则用户的令牌应包括来自两个域的组。

    【讨论】:

    • 简短的回答是这会起作用。只花了几个小时测试这个。我的印象是来自 WindowsIdentity.Groups 属性的组可能是陈旧的或不完整的。这是真的,但似乎在跨域边界访问服务时,令牌总是新鲜的。好电话。
    猜你喜欢
    • 1970-01-01
    • 2012-08-03
    • 2015-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多