我正在使用带有 SocialAndLocalAccounts 包的自定义策略入门包。
对我来说很好。
但是我面临一个问题。成功登录后,我需要获取电子邮件作为声明。 我已经收到电子邮件声明,一旦用户已注册并立即重定向回应用程序。
但是当用户只是登录时我没有得到它。
我该怎么办? 要在声明中获取电子邮件的价值,我需要在哪里写输出声明?
请帮助我。 谢谢
答案 0 :(得分:3)
以下内容介绍了如何保存,加载并根据注册/登录和密码重置策略将 otherMails 声明作为 emails 发出。
编写本地帐户时:您必须使用 CreateOtherMailsFromEmail 声明转换从 email 声明中创建 otherMails 声明,然后保留< AAD-UserWriteUsingLogonEmail 技术资料中的strong> otherMails 声明:
<TechnicalProfile Id="AAD-UserWriteUsingLogonEmail">
...
<IncludeInSso>false</IncludeInSso>
<InputClaimsTransformations>
<InputClaimsTransformation ReferenceId="CreateOtherMailsFromEmail" />
</InputClaimsTransformations>
<InputClaims>
...
</InputClaims>
<PersistedClaims>
...
<PersistedClaim ClaimTypeReferenceId="otherMails" />
</PersistedClaims>
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="otherMails" />
</OutputClaims>
...
</TechnicalProfile>
然后,您必须从 LocalAccountSignUpWithLogonEmail 技术资料中传递 otherMails 声明,该技术资料被调用来注册本地帐户:
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
...
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="otherMails" />
</OutputClaims>
</TechnicalProfile>
编写社交帐户时: otherMails 声明已经从 email 声明中创建,然后保留在 AAD-UserWriteUsingAlternativeSecurityId 技术资料中
然后,您必须从 SelfAsserted-Social 技术资料中传递 otherMails 声明,该资料被调用来注册社交帐户:
<TechnicalProfile Id="SelfAsserted-Social">
...
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="otherMails" />
</OutputClaims>
</TechnicalProfile>
在阅读本地帐户或社交帐户时: otherMails 声明已在 AAD-UserReadUsingObjectId , AAD-UserReadUsingEmailAddress 和< strong> AAD-UserReadUsingAlternativeSecurityId 技术资料。
然后,您必须从 LocalAccountDiscoveryUsingEmailAddress 技术档案中传递 otherMails 声明,该档案将被调用以恢复本地密码:
<TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
...
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="otherMails" />
</OutputClaims>
</TechnicalProfile>
要通过注册/登录和密码重置策略将 otherMails 声明为 email ,请执行以下操作:您必须添加 otherMails 声称是<OutputClaim />
的依赖方政策:
<RelyingParty>
...
<TechnicalProfile Id="PolicyProfile">
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="otherMails" PartnerClaimType="emails" />
</OutputClaims>
</TechnicalProfile>
</RelyingParty>
答案 1 :(得分:1)
对于Chris Padgett的回答,您可以在声明中添加其他电子邮件(备用电子邮件)。
如果您只想将登录名中的电子邮件声明添加到令牌中,则可以执行以下步骤:
打开您的SignUporSignIn.xml
文件
将<OutputClaim ClaimTypeReferenceId="email" />
替换为<OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" PartnerClaimType="email" />
保存此SignUporSignIn.xml文件并将其上传到Azure AD B2C以覆盖该策略。
希望这会有所帮助。