如何从Azure B2C在ASPCore中获得OID声明 [英] How do I get an OID claim in ASPCore from Azure B2C

查看:71
本文介绍了如何从Azure B2C在ASPCore中获得OID声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为什么要这个?

我正在尝试从用户那里获取一个唯一的标识符,该标识符可以连接到数据库记录.有一些原因我不想使用电子邮件作为标识符.我读到B2C不支持SUB声明,而是在其中使用OID.

I'm trying to get a unique identifier from my user which I can connect to database records. There are reasons I don't want to use the Email as the identifier. I read that SUB claim isn't supported with B2C, and to use OID in it's place.

我已采取的步骤

因此,我将两个策略都设置为在Azure B2C上返回对象ID:

So, I've set up that both of my policies return Object ID on Azure B2C:

目前,我正在使用单独的登录"和注册"策略,并且收回了所有声明,包括我指定要退回的电子邮件声明.但是,我找不到与OID或SUB相关的声明.

I'm using individual SignIn and SignUp policies at the moment, and I get all of the claims back, including the email claim which I specified I wanted to be returned. I cannot however find a claim related to OID or SUB.

User.Claims 

得到以下结果:

我发现的唯一希望就是这样的说法:

The single breadcrumb of hope that I have found is this claim:

类型: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier

值:当前不支持.使用oid声明.

Value: Not supported currently. Use oid claim.

问题

我是否错过了您需要执行一些其他步骤才能检索此特定声明的步骤?

Have I missed some additional step that you need to perform to retrieve this particular claim?

有人成功从Azure B2C检索OID或SUB吗?

Has anyone had any success retrieving an OID or SUB from Azure B2C?

推荐答案

好吧,这很尴尬,我必须看过这条线大约30次了,却没有注意到...

Well, this is embarrassing, I must have looked over this line about 30 times and not noticed...

我正在检索OID令牌,它的声明类型为:

I was retrieving the OID token, it's claim type was:

http://schemas.microsoft.com/identity/claims/objectidentifier

在我提供的屏幕截图中可以清楚地看到.我将把这个问题搁置一旁,因为该架构可能会使其他人失望.

As can be clearly seen in my provided screenshots. I'll leave this question up as, the schema may throw someone else off.

这篇关于如何从Azure B2C在ASPCore中获得OID声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆