【问题标题】:Thread.CurrentPrincipal has null details on AzureThread.CurrentPrincipal 在 Azure 上的详细信息为空
【发布时间】:2014-11-19 01:01:12
【问题描述】:

我们正在尝试使用 Thred.CurrentPrincipal 来获取用户信息。但是,一旦我们将其部署到 Azure,CurrentPrincipal 就会为空。

var td = new TokenData();

var claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;

if (claimsPrincipal != null)
{
    td.IsAuthenticated = claimsPrincipal.Identity.IsAuthenticated;

    td.Name = claimsPrincipal.FindFirst(ClaimTypes.Name).Value;
    td.Email = claimsPrincipal.FindFirst(ClaimTypes.Upn).Value;
    td.Surname = claimsPrincipal.FindFirst(ClaimTypes.Surname).Value;
    td.Role = claimsPrincipal.FindAll("http://schemas.xmlsoap.org/claims/Group")
        .Select(s=>s.Value);
}

我确认 ADFS 设置正确。如果有人能指出我的痛点,那就太好了。

编辑:

CurrentPrincipal 不是 NULL,但细节是。所以我们没有得到用户的姓名、角色和其他详细信息。

编辑 2:

这就是 Azure 上正在发生的事情:

【问题讨论】:

    标签: c# asp.net-mvc azure azure-web-app-service adfs


    【解决方案1】:

    您可能需要打开用户配置文件才能让您的主体工作。

    打开它在您网站的门户中,转到配置 -> 应用程序设置并添加应用程序设置 WEBSITE_LOAD_USER_PROFILE = 1。您的网站需要处于基本或标准模式才能工作。

    【讨论】:

    • 感谢您的建议,但这并没有解决我的问题。我会用更多细节更新我的问题。
    • 其实让我再检查一下,因为我的网站处于免费模式。
    • 我可以确认缩放网站并添加参数并没有解决问题。
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 2020-05-09
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    相关资源
    最近更新 更多