【问题标题】:Enumerating Groups using WindowsIdentity.GetCurrent() returns old set of groups使用 WindowsIdentity.GetCurrent() 枚举组返回旧组集
【发布时间】:2011-02-01 22:33:36
【问题描述】:

我有一个用户,当我尝试使用以下任一方法枚举她的组时 System.Security.Principal.WindowsIdentity.GetCurrent().Groups 在用户的计算机上 或 System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups 在 IIS 服务器上,我得到了他们旧组的列表,而不是他们的新组。

我已经检查了他们进行身份验证的 DC,并且 ASP.NET 页面在 SharePoint 实例中运行,因此最喜欢的 LogonUserIdentity 是从那里提供的 Kerberos 票证。

我是否应该直接从 AD 中查找组,而不是依赖 WindowsIdentity 或 LogonUserIdentity?

【问题讨论】:

  • 这样就完成了循环。该组的令牌从未刷新,直到她被添加回旧组并再次被删除。此外,她被从新组中删除并重新添加到组中。这足以导致某些内容被重置并强制组在 LoginUserIdentity 中正确表示。

标签: asp.net active-directory credentials


【解决方案1】:

如果您使用WindowsIdentityLogonUserIdentity,它将从存储在 Kerberos 票证授予票证 (TGT) 中的授权数据中检索组信息。

它功能强大且有用,因为一旦您通过身份验证并获得 Kerberos TGT,您无需再次查询 Active Directory 即可获取所有组信息。实际上,组枚举非常昂贵且复杂。因此,首选 Kerberos 票证方法,并且在您访问任何 Windows 资源时都会使用此方法。

但是,这也意味着在您将用户帐户添加到组后,WindowsIdentityLogonUserIdentity 方法将不知道新添加的组。您必须清除您的 Kerberos 票证并重新获得它。您可以注销然后登录,也可以锁定屏幕并输入密码以解锁屏幕。

如果由于某些原因,您仍想自己进行组枚举,我建议您在 .NET 3.5 中使用UserPrincipal.GetAuthorizationGroups。它返回用户所属的所有安全组。

【讨论】:

  • 我知道这是一个老问题,但是否有任何文档显示注销并重新登录会强制更新 WindowsIdentity.GetCurrent().Groups?我想确保在用户注销并重新登录后,组每次都会更新 - 目前在 MSDN 上找不到任何内容
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-20
  • 2019-06-08
  • 2011-04-09
  • 1970-01-01
  • 2019-03-22
  • 2015-11-28
  • 2013-01-17
相关资源
最近更新 更多