繁体   English   中英

Thread.CurrentPrincipal在Azure上具有空详细信息

[英]Thread.CurrentPrincipal has null details on Azure

我们正在尝试使用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上发生的事情:

在Azure上进行远程调试

在Azure上进行远程调试

您可能需要打开“用户配置文件”才能使主体工作。

启用它在您网站的门户中,转到“配置”->“应用程序设置”,然后添加应用程序设置WEBSITE_LOAD_USER_PROFILE =1。您的网站必须处于“基本”或“标准”模式才能正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM