Azure active directory ASP.NET5与Azure的身份验证-声明似乎已更改 简要地

Azure active directory ASP.NET5与Azure的身份验证-声明似乎已更改 简要地,azure-active-directory,adfs,asp.net-authentication,microsoft-identity-web,Azure Active Directory,Adfs,Asp.net Authentication,Microsoft Identity Web,在使用Azure ADFS进行身份验证时,我是否应该使用OpenIdConnectDefaults.AuthenticationScheme 更详细地 我有一个ASP.NET核心应用程序,最近已从3.1升级到.NET 5 在此之前,它一直在使用以下NuGet包: <PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.1.9" />

在使用Azure ADFS进行身份验证时,我是否应该使用
OpenIdConnectDefaults.AuthenticationScheme

更详细地 我有一个ASP.NET核心应用程序,最近已从3.1升级到.NET 5

在此之前,它一直在使用以下NuGet包:

<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.1.9" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="5.0.3" />
今天,我更新了NuGet软件包:

<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.1.9" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="5.0.3" />
这将返回带有电子邮件地址的索赔

但是,现在返回null

以下代码使用电子邮件地址获取索赔:

Claim? upnClaim = identity.FindFirst("preferred_username");
所以,我可以用这个来运行,它会起作用

但是,我想知道使用
OpenIdConnectDefaults.AuthenticationScheme
是否是最新Microsoft Identity和Azure ADFS的首选选项?事实上,我不得不使用一个神奇的字符串“preferred_username”而不是
ClaimTypes.Upn
,这让我有些怀疑

有人对此有深刻的见解吗

事实上,我不得不使用一个神奇的字符串“preferred\u username”而不是ClaimTypes.Upn,这让我有些怀疑

preferred\u username
不是一个神奇的字符串,它被记录为AAD添加到id令牌负载的声明之一,请参阅

ASP.NET核心OpenID Connect提供程序使用的底层库,用于映射声明以匹配.NET世界中的已知声明。可能Microsoft.Identity.Web会禁用该特定行为


不久前,我在上写了一篇关于这一点的博客。

一直在阅读这些链接-非常有用。我认为Microsoft建议使用不可变且非人类可读的声明(如
oid
)来识别用户以进行授权。我完全理解这一点。但是,我如何才能找到我的同事
oid
值?我没有域管理员权限。cmd
net user username/domain
似乎没有返回此信息。如果您在>Azure Active Directory>用户>搜索某人>单击其配置文件登录Azure门户,您应该能够看到此信息。也可以使用PowerShell的
获取AzureADUser
Claim? upnClaim = identity.FindFirst("preferred_username");