简体   繁体   English

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

[英]Thread.CurrentPrincipal has null details on Azure

We are trying to use Thred.CurrentPrincipal to get the user information. 我们正在尝试使用Thred.CurrentPrincipal来获取用户信息。 However as soon as we deploy it to Azure the CurrentPrincipal is null. 但是,一旦将其部署到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);
}

I verified that ADFS is set-up correctly. 我确认ADFS设置正确。 It would be great if someone could point me to the pain-point of this. 如果有人可以指出我的痛苦点,那就太好了。

Edit: 编辑:

The CurrentPrincipal is not NULL but the details are. CurrentPrincipal不是NULL,但详细信息是。 So we are not getting the user's name, roles and other details. 因此,我们没有得到用户的姓名,角色和其他详细信息。

Edit 2: 编辑2:

This is what is happening on Azure: 这是在Azure上发生的事情:

在Azure上进行远程调试

在Azure上进行远程调试

You might need to turn on User Profiles in order to get your principal to work. 您可能需要打开“用户配置文件”才能使主体工作。

To turn it on In the portal on your website go to Configuration -> App Settings and add the app setting WEBSITE_LOAD_USER_PROFILE = 1. You site needs to be in Basic or Standard mode for this to work. 启用它在您网站的门户中,转到“配置”->“应用程序设置”,然后添加应用程序设置WEBSITE_LOAD_USER_PROFILE =1。您的网站必须处于“基本”或“标准”模式才能正常工作。

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

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