You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过API在Azure AD中配置本地IDP?调用availableProviderTypes未返回该类型

Azure AD B2C 本地账户IDP的API配置方案

为什么GET /identity/identityProviders/availableProviderTypes看不到本地账户类型?

本地账户是Azure AD B2C的原生内置身份系统,不属于外部身份提供商范畴,因此该API仅返回第三方身份提供商类型,不会包含本地账户。

通过API配置本地账户的正确方式

本地账户的配置是与**用户流(User Flows)或自定义策略(Custom Policies)**绑定的,以下是具体实现步骤:


1. 通过用户流API启用并配置本地账户

用户流是B2C中快速配置认证流程的方式,创建或更新用户流时可直接启用本地账户并设置相关规则:

创建支持本地账户的登录/注册用户流
POST https://graph.microsoft.com/v1.0/identity/b2cUserFlows
Content-Type: application/json

{
  "id": "B2C_1_signup_signin",
  "userFlowType": "signUpOrSignIn",
  "userFlowTypeVersion": 1,
  "identityProviders": [
    {
      "id": "LocalAccount",
      "type": "LocalAccount",
      "name": "Local Account",
      "clientId": "local-account",
      "enabled": true
    }
  ],
  "passwordConfiguration": {
    "passwordStrength": "Strong",
    "passwordHistoryCount": 5,
    "resetPasswordEnabled": true,
    "forgotPasswordEnabled": true
  },
  "userAttributes": [
    {
      "name": "displayName",
      "required": true
    },
    {
      "name": "email",
      "required": true
    }
  ]
}
修改现有用户流的本地账户设置

如果已有用户流,可通过PATCH请求更新本地账户的启用状态或密码规则:

PATCH https://graph.microsoft.com/v1.0/identity/b2cUserFlows/B2C_1_signup_signin
Content-Type: application/json

{
  "identityProviders": [
    {
      "id": "LocalAccount",
      "enabled": true
    }
  ],
  "passwordConfiguration": {
    "passwordStrength": "Medium",
    "passwordHistoryCount": 3
  }
}

2. 自定义策略场景下的API配置

若使用自定义策略(适用于复杂认证场景),需先编写包含本地账户认证逻辑的策略文件(如TrustFrameworkBase.xml中定义LocalAccountSigninEmailExchange等技术配置),再通过以下API上传策略:

PUT https://graph.microsoft.com/v1.0/trustframework/policies/B2C_1A_base/$value
Content-Type: application/xml

<!-- 此处填入自定义策略的XML内容 -->

关键说明

  • 本地账户不是独立的"身份提供商"资源,而是集成在B2C的用户认证流程中,因此无法通过identityProviders相关API单独添加。
  • 所有本地账户的核心配置(如登录方式、密码规则、账户锁定)均需通过用户流或自定义策略的API进行管理。

内容的提问来源于stack exchange,提问作者Nikil Lepcha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 17:47:32