首次登录时重置密码期间出现 Azure AD B2C 错误(使用自定义策略)

2023-11-29

我尝试在首次登录(在 Azure ADB2C 中)后使用自定义策略强制重置密码,如中所述“重置密码”存储库.

我正在使用自定义策略,并且在尝试上传“SignUpOrSignin.xml”自定义策略时出现验证错误。消息是:

未找到键为“ApplicationObjectId”的必需元数据项 在带有 id 的 TechnicalProfile 中 策略中的“AAD-UserRemoveMustResetPasswordUsingObjectId” 租户“resetpasswordtest.onmicrosoft.com”的“B2C_1A_signup_signin”

这些是我遵循的步骤:

  1. 我从以下位置下载了自定义策略 XML 文件thisGitHub 示例(如末尾所述自述文件.md)
  2. 我“替换”了“yourtenant.onmicrosoft.com”和“facebook 客户端”
  3. 我将“SignUpOrSignin.xml”和“TrustFrameworkExtensions.xml”与以下内容“合并”“重置密码”存储库.
  4. 我创建了“mustResetPassword”扩展属性(使用 Azure 门户)
  5. 我使用图形实用程序创建了一个用户(因此我 100% 确定该用户是使用正确的“必须重置密码”扩展属性以安全方式创建的)
  6. 最后,我将以下 xml 上传到门户(按顺序):

TrustFrameworkBase.xml

TrustFrameworkExtensions.xml

密码重置.xml

配置文件编辑.xml

注册或登录.xml

当我尝试上传最后一个 (SignUpOrSignin.xml) 时出现问题 这里有什么问题吗?Here您可以找到前面 5 个 xml 文件的完整实现。

请查看以下部分,我在其中粘贴了“TrustFrameworkExtensions.xml”和“SignUpOrSignin.xml”自定义策略。

谢谢阅读

<TrustFrameworkPolicy 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06" 
  PolicySchemaVersion="0.3.0.0" 
  TenantId="resetpasswordtest.onmicrosoft.com" 
  PolicyId="B2C_1A_TrustFrameworkExtensions" 
  PublicPolicyUri="http://resetpasswordtest.onmicrosoft.com/B2C_1A_TrustFrameworkExtensions">
  
  <BasePolicy>
    <TenantId>resetpasswordtest.onmicrosoft.com</TenantId>
    <PolicyId>B2C_1A_TrustFrameworkBase</PolicyId>
  </BasePolicy>
  <BuildingBlocks>
  <ClaimsSchema>
    <!--Demo: Specifies whether user must reset the password-->
    <ClaimType Id="extension_mustResetPassword">
        <DisplayName>Must reset password</DisplayName>
        <DataType>boolean</DataType>
        <UserHelpText>Specifies whether user must reset the password</UserHelpText>
      </ClaimType>
  </ClaimsSchema>
  </BuildingBlocks>

  <ClaimsProviders>
   <ClaimsProvider>
      <DisplayName>Azure Active Directory</DisplayName>
      <TechnicalProfiles>  

        <TechnicalProfile Id="AAD-UserReadUsingObjectId">
          <OutputClaims>
            <!--Demo: Read the 'must reset password' extension attribute -->
            <OutputClaim ClaimTypeReferenceId="extension_mustResetPassword" />
          </OutputClaims>
        </TechnicalProfile>

        <TechnicalProfile Id="AAD-UserRemoveMustResetPasswordUsingObjectId">
          <Metadata>
            <Item Key="Operation">DeleteClaims</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
          </InputClaims>
          <PersistedClaims>
            <PersistedClaim ClaimTypeReferenceId="objectId" />
            <PersistedClaim ClaimTypeReferenceId="extension_mustResetPassword" />            
          </PersistedClaims>
          <IncludeTechnicalProfile ReferenceId="AAD-Common" />
        </TechnicalProfile>

        <!--Demo: to create the extension attribute extension_mustResetPassword, you should upload the policy 
            and create one account. Then ***comment out this technical profile***.
            -->
        <TechnicalProfile Id="AAD-UserWriteUsingLogonEmail">
          <PersistedClaims>
            <PersistedClaim ClaimTypeReferenceId="extension_mustResetPassword" DefaultValue="true" />
          </PersistedClaims>
        </TechnicalProfile>
      </TechnicalProfiles>
    </ClaimsProvider>

    <!-- Facebook claims provider -->
    <ClaimsProvider>
      <DisplayName>Facebook</DisplayName>
      <TechnicalProfiles>
        <TechnicalProfile Id="Facebook-OAUTH">
          <Metadata>
            <!--Demo action required: Change to your Facebook App Id-->
            <Item Key="client_id">313412440187068</Item>
            <Item Key="scope">email public_profile</Item>
            <Item Key="ClaimsEndpoint">https://graph.facebook.com/me?fields=id,first_name,last_name,name,email</Item>
          </Metadata>
        </TechnicalProfile>
      </TechnicalProfiles>
    </ClaimsProvider>


    <ClaimsProvider>
      <DisplayName>Local Account SignIn</DisplayName>
      <TechnicalProfiles>
        <TechnicalProfile Id="login-NonInteractive">
          <Metadata>
            <Item Key="client_id">44444444-2222-2222-2222-555555555555</Item>
            <Item Key="IdTokenAudience">44444444-2222-2222-2222-555555555555</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="client_id" DefaultValue="44444444-2222-2222-2222-555555555555" />
            <InputClaim ClaimTypeReferenceId="resource_id" PartnerClaimType="resource" DefaultValue="44444444-2222-2222-2222-555555555555" />
          </InputClaims>
        </TechnicalProfile>
      </TechnicalProfiles>
    </ClaimsProvider>

  </ClaimsProviders>

  <UserJourneys>
    <UserJourney Id="SignUpOrSignInWithForcePasswordReset">
      <OrchestrationSteps>
      
        <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
          <ClaimsProviderSelections>
            <ClaimsProviderSelection TargetClaimsExchangeId="FacebookExchange" />
           <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
          </ClaimsProviderSelections>
          <ClaimsExchanges>
            <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!-- Check if the user has selected to sign in using one of the social providers -->
        <OrchestrationStep Order="2" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
              <Value>objectId</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="FacebookExchange" TechnicalProfileReferenceId="Facebook-OAUTH" />
           <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!-- For social IDP authentication, attempt to find the user account in the directory. -->
        <OrchestrationStep Order="3" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
              <Value>authenticationSource</Value>
              <Value>localAccountAuthentication</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="AADUserReadUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserReadUsingAlternativeSecurityId-NoError" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!-- Show self-asserted page only if the directory does not have the user account already (i.e. we do not have an objectId). 
          This can only happen when authentication happened using a social IDP. If local account was created or authentication done
          using ESTS in step 2, then an user account must exist in the directory by this time. -->
        <OrchestrationStep Order="4" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
              <Value>objectId</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="SelfAsserted-Social" TechnicalProfileReferenceId="SelfAsserted-Social" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!-- This step reads any user attributes that we may not have received when authenticating using ESTS so they can be sent 
          in the token. -->
        <OrchestrationStep Order="5" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
              <Value>authenticationSource</Value>
              <Value>socialIdpAuthentication</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!--Demo: check if change password is required. If yes, ask the user to reset the password-->
        <OrchestrationStep Order="6" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
              <Value>authenticationSource</Value>
              <Value>socialIdpAuthentication</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="false">
              <Value>extension_mustResetPassword</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>            
            <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
              <Value>extension_mustResetPassword</Value>
              <Value>True</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>            
          </Preconditions>        
          <ClaimsExchanges>
            <ClaimsExchange Id="NewCredentials" TechnicalProfileReferenceId="LocalAccountWritePasswordUsingObjectId" />
          </ClaimsExchanges>
        </OrchestrationStep>
          <!--Demo: check if change password is required. If yes remove the value of the extension attribute. 
              So, on the next time user dons' t need to update the password-->
        <OrchestrationStep Order="7" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
              <Value>authenticationSource</Value>
              <Value>socialIdpAuthentication</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="false">
              <Value>extension_mustResetPassword</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>            
            <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
              <Value>extension_mustResetPassword</Value>
              <Value>True</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>            
          </Preconditions>        
          <ClaimsExchanges>
            <ClaimsExchange Id="AADUserRemoveMustResetPasswordUsingObjectId" TechnicalProfileReferenceId="AAD-UserRemoveMustResetPasswordUsingObjectId" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <!-- The previous step (SelfAsserted-Social) could have been skipped if there were no attributes to collect 
             from the user. So, in that case, create the user in the directory if one does not already exist 
             (verified using objectId which would be set from the last step if account was created in the directory. -->
        <OrchestrationStep Order="8" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
              <Value>objectId</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="AADUserWrite" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
          </ClaimsExchanges>
        </OrchestrationStep>
 
        <OrchestrationStep Order="9" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
 
      </OrchestrationSteps>
      <ClientDefinition ReferenceId="DefaultWeb" />
    </UserJourney>
  </UserJourneys>

</TrustFrameworkPolicy>
<TrustFrameworkPolicy
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06"
  PolicySchemaVersion="0.3.0.0"
  TenantId="resetpasswordtest.onmicrosoft.com"
  PolicyId="B2C_1A_signup_signin"
  PublicPolicyUri="http://resetpasswordtest.onmicrosoft.com/B2C_1A_signup_signin">

  <BasePolicy>
    <TenantId>resetpasswordtest.onmicrosoft.com</TenantId>
    <PolicyId>B2C_1A_TrustFrameworkExtensions</PolicyId>
  </BasePolicy>

  <RelyingParty>
    <DefaultUserJourney ReferenceId="SignUpOrSignInWithForcePasswordReset" />
    <TechnicalProfile Id="PolicyProfile">
      <DisplayName>PolicyProfile</DisplayName>
      <Protocol Name="OpenIdConnect" />
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="displayName" />
        <OutputClaim ClaimTypeReferenceId="givenName" />
        <OutputClaim ClaimTypeReferenceId="surname" />
        <OutputClaim ClaimTypeReferenceId="email" />
        <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub"/>
        <OutputClaim ClaimTypeReferenceId="identityProvider" />
        <OutputClaim ClaimTypeReferenceId="tenantId" AlwaysUseDefaultValue="true" DefaultValue="{Policy:TenantObjectId}" />
      </OutputClaims>
      <SubjectNamingInfo ClaimType="sub" />
    </TechnicalProfile>
  </RelyingParty>
</TrustFrameworkPolicy>

您错过了配置扩展属性支持的策略。https://learn.microsoft.com/en-us/azure/active-directory-b2c/user-flow-custom-attributes?pivots=b2c-custom-policy#azure-ad-b2c-extensions-app

整个过程可以使用我的工具自动化:https://aka.ms/iefsetup在开始使用样品之前。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

首次登录时重置密码期间出现 Azure AD B2C 错误(使用自定义策略) 的相关文章

随机推荐

  • R 中的日期函数返回错误的年份

    我正在尝试将字符字段转换为日期字段 其中的选项可以使用strptime函数或as Date功能 这是两个可重现的示例 strptime c 5 13 2015 m d y result is 2020 05 13 MST as Date c
  • 如何直接从 Azure blob 存储读取文本文件而不将其下载到本地文件(使用 python)?

    如何在不下载的情况下读取 Azure 中的文本 blob 我可以下载该文件然后阅读它 但是 我更喜欢在不下载的情况下阅读它 print nList blobs in the container generator block blob se
  • 为什么矩形跳跃的高度会变化?

    为什么矩形跳跃的高度会变化 似乎是在循环 首先它跳得很低 然后根本不跳 然后它跳得很高 然后根本不跳 我不明白为什么使用相同的代码并且它是由相同的事件触发的 import java awt Color import java awt Gra
  • ColumnText 中短语的 iText 放置

    所以我正在处理一种情况 我将一个 Phrase 添加到 ColumnText 对象中 黑色标题是 iText 将短语文本放置在 ColumnText 中的位置 粉红色的标题是所需的位置 private void addText PdfCon
  • DataGridView 最右列用户增加大小不起作用

    I have a strange issue with a DataGridView on a WinForm I can resize all columns via mouse but for the rightmost I can o
  • Clojure 中的 ClassCastException

    我是 clojure 的新手 我一直在尝试不同的程序 这是我的程序 defn sdsu reverse x loop n count x x x if 0 n x recur n 1 conj next x first x sdsu rev
  • Javascript:如何从 UTC 字符串和偏移量解析日期?

    Scenario 我有一个字符串格式的 UTC 日期和一个以分钟为单位的关联偏移量 日期 2017 10 01T12 00 00 000Z 偏移 360 用户的浏览器位于山区标准时间 7 时区 日期值是从中央标准时间 6 时区记录的 并与其
  • 如何在自定义插件中使用 WordPress 文本编辑器

    我们如何为我的 WordPress 插件使用默认的 WordPress 文本编辑器 请问有什么建议吗 WordPress 文本编辑器是一个应用程序TinyMCE 编辑器 您可以利用位于 wp includes js tinymce 中的文件
  • XPATH 和默认命名空间

    XPath 和命名空间支持背后的故事是什么 XPath 作为规范是否先于命名空间 如果我有一个文档 其中的元素已被赋予默认名称空间
  • 为什么查询在超时限制内会超时?

    我有一个长时间运行的查询 大约 48 分钟后超时 命令超时设置为 2 小时 连接超时设置为 17 分钟 什么会导致查询超时 我假设一定还有其他我忽略的事情 Npgsql NpgsqlException A timeout has occur
  • 图像宽度/高度作为属性还是在 CSS 中? [复制]

    这个问题在这里已经有答案了 指定图像高度和宽度的 正确 语义方式是什么 在 CSS 中 width 15px 或内联 img width 15 宽度似乎与 src 一样与二进制图像数据相关 是的 我意识到从技术和最终用户的角度来看 这确实不
  • 获取用户关注者数量 1.1 - 410 Gone

    我正在尝试构建一个 关注 按钮 其上方有垂直关注者计数 我有一个解决方案一直有效 直到 Twitter 今天停用 1 0 API 现在需要 Oauth 解决方案 我的问题是 最好 最简单的解决方案是什么 最好是 JS 这是旧的解决方案 ge
  • 使用相关子查询更新查询

    我正在尝试将 Foxpro 应用程序转换为 NET 作为转换的一部分 我将数据从 DBF 表转换到 Sql 服务器 我需要根据 Orders 表 FirstOrder 和 LastOrder 在 Customer 表中添加几个新字段 我似乎
  • 嵌套 STL 向量使用太多内存

    我有一个STL向量My Partition Vector of Partition对象 定义为 struct Partition the event log data structure int key std vector
  • 为什么解析 json 字符串时 eval('(' + jsonString+ ')') 的左引号和括号

    你能告诉我这个特定语法结构的原因吗 eval jsonString 解析json文本时 克罗克福德说 文本必须用括号括起来 以避免 JavaScript 语法中出现歧义 here 这意味着什么 我们能避免吗 Crockford 提到的语法歧
  • 在 Pyside/PyQt 中通过 http post 上传文件

    我正在尝试将文件和其他 POST 变量发送到我的客户服务器上的 xfilesharing 脚本 位于 perl 中 Google 上没有好的资源 而且我发现的代码示例不起作用 实际上它们是用 C 编写的 我无法让它们工作 服务器使用 Apa
  • 仅读取 CSV 文件中的多个列中的特定列

    我有一个 CSV 文件 基本上如下所示 TransactionID ProfileID Date more columns here somevalue 123123123 somedate somevalue 123123123 some
  • CGImageDestination 和文件命名问题

    我正在使用 AVCapture 从相机捕获图像 因为我需要速度 而标准套件的速度太慢了 我遇到的问题是 正在输出的文件 动画 GIF 的文件名被 CGImageDestination 函数破坏 当我将 NSURL 转换为 CFURLRef
  • 如何查找警告的原因:PropTypes 已移至单独的包中

    如果我收到警告 警告 PropTypes 已移至单独的包中 如何找到哪个 npm 包仍在使用它 该警告没有提供有关导致该问题的文件或包的任何详细信息 React 不推荐使用propTypes从他们的主包中 所以你不能使用React Prop
  • 首次登录时重置密码期间出现 Azure AD B2C 错误(使用自定义策略)

    我尝试在首次登录 在 Azure ADB2C 中 后使用自定义策略强制重置密码 如中所述 重置密码 存储库 我正在使用自定义策略 并且在尝试上传 SignUpOrSignin xml 自定义策略时出现验证错误 消息是 未找到键为 Appli