【问题标题】:How to Get Current User Principal如何获取当前用户主体
【发布时间】:2014-02-27 13:52:26
【问题描述】:

我想使用 Windows 身份验证并获取用户信息,例如 Givenname、Surname 等。 我在 IIS 中使用了UserPrincipal.Current,但遇到了异常,但 IIS express 看起来不错。

【问题讨论】:

    标签: asp.net windows-authentication userprincipal groupprincipal


    【解决方案1】:

    我使用查找方法解决了:

    var domain = new PrincipalContext(ContextType.Domain);
    var currentUser = UserPrincipal.FindByIdentity(domain, User.Identity.Name);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-03
      • 2021-07-16
      • 2012-03-21
      • 2020-07-19
      • 1970-01-01
      • 2014-08-21
      • 2011-12-02
      • 2010-11-11
      相关资源
      最近更新 更多