azure-ad-b2c - 身份体验框架和社交账户
问题描述
我制定了一个策略,允许使用用户名和密码(B2C 用户)或使用 Microsoft 帐户登录,将 AD 连接为 OpenId 身份提供程序。它工作正常,但是当我使用我的 Microsoft 帐户登录时,未设置电子邮件:
我想我必须在以下代码段中设置一些东西:
<TechnicalProfile Id="AAD-UserWriteUsingAlternativeSecurityId">
<Metadata>
<Item Key="Operation">Write</Item>
<Item Key="RaiseErrorIfClaimsPrincipalAlreadyExists">true</Item>
<Item Key="UserMessageIfClaimsPrincipalAlreadyExists">You are already registered, please press the back button and sign in instead.</Item>
</Metadata>
<IncludeInSso>false</IncludeInSso>
<InputClaimsTransformations>
<InputClaimsTransformation ReferenceId="CreateOtherMailsFromEmail" />
</InputClaimsTransformations>
<InputClaims>
<InputClaim ClaimTypeReferenceId="AlternativeSecurityId" PartnerClaimType="alternativeSecurityId" Required="true" />
</InputClaims>
<PersistedClaims>
<!-- Required claims -->
<PersistedClaim ClaimTypeReferenceId="alternativeSecurityId" />
<PersistedClaim ClaimTypeReferenceId="userPrincipalName" />
<PersistedClaim ClaimTypeReferenceId="mailNickName" DefaultValue="unknown" />
<PersistedClaim ClaimTypeReferenceId="displayName" DefaultValue="unknown" />
<!-- Optional claims -->
<PersistedClaim ClaimTypeReferenceId="otherMails" />
<PersistedClaim ClaimTypeReferenceId="givenName" />
<PersistedClaim ClaimTypeReferenceId="surname" />
</PersistedClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectId" />
<OutputClaim ClaimTypeReferenceId="newUser" PartnerClaimType="newClaimsPrincipalCreated" />
<OutputClaim ClaimTypeReferenceId="otherMails" />
</OutputClaims>
<IncludeTechnicalProfile ReferenceId="AAD-Common" />
<UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
</TechnicalProfile>
我试图添加<PersistedClaim ClaimTypeReferenceId="email"/>
到 中PersistedClaims
,但收到错误请求并显示消息:指定的一个或多个属性值无效。
在此页面上,我看到正确的定义是mail
. 我还尝试定义一个新的ClaimType
并使用 aClaimsTransformation
从 中获取值otherMails
,但该字段未设置。
解决方案
这将不起作用:
<PersistedClaim ClaimTypeReferenceId="email"/>
因为在名为“email”的用户对象上没有这样的属性。
你可以做的是:
<PersistedClaim ClaimTypeReferenceId="email" PartnerClaimType="signInNames.emailAddress"/>
然后,这将显示userPrincipalName
在 Azure 门户中。这也意味着用户无法使用该电子邮件注册本地帐户,实际上您创建了一个“双重/链接帐户”,尽管没有密码。然后,用户需要重置此帐户的密码才能使用用户名和密码访问它,例如,如果他们曾经在 Facebook 上删除了他们的社交帐户。
另一种选择是写到otherMails
<PersistedClaim ClaimTypeReferenceId="email" PartnerClaimType="otherMails"/>
这可能需要是一个数组,因此在写入之前先使用 claimTransform 构建一个数组。
不要将电子邮件写入mail
属性,B2C 帐户支持的属性在此处。
推荐阅读
- r - 将图例添加到 R 中的图形
- matlab - 如何在不使用 for 循环的情况下对不同大小的矩阵的各个部分求和?
- c# - 用于在 Windows 中使用 AuthenticateAsServer() 的 localhost 的 x509 证书
- unicode - Keyman developer 10 将不匹配 Odia 脚本中的规则
- iot - 用于模仿 IoT 代理命令的 NGSI v2 端点是什么?
- ms-access - Jet SQL/MS Access - 按用户查询、任务计数、时间总和
- git - 我怎样才能回到以前的提交,删除我在本地/公共仓库中发布的所有内容?
- java - 模拟 SOAP 请求和响应
- ios - 更改不同屏幕上的导航栏颜色和标题颜色
- python - Python:从csv中提取特定行作为列表