如何在 AD B2C 中预先创建 "business customers"
How to pre-create "business customers" in AD B2C
我正在构建一个载入网络应用程序来为我的 LOB 应用程序配置用户。我的大多数客户都是 "business customers",这意味着他们通常会被自定义策略定向到 v1 公共端点,从而允许他们针对自己的 AAD 租户进行身份验证。挑战在于新用户也需要在 LOB 应用程序中进行后续配置(创建数据库用户、分配一些权限等)。
作为入职的一部分,我想做的是调用 graphAPI 来创建将成为 b2c 中的联合用户帐户的内容,然后使用返回的新用户 objectId 处理特定于我的后续设置LOB 应用程序。理想情况下,当用户第一次到达时,他们将被重定向到针对他们自己的 AAD 的身份验证,然后映射到 b2c 中预先创建的用户,最后登陆具有已配置和准备好的 objectId 的 LOB 应用程序。
这是对自定义策略和 graphAPI 进行一些创造性使用的受支持方案吗?
谢谢
马克
您有以下选择:
- 使用外部电子邮件地址和 link 使用此本地帐户用户的外部用户身份创建本地帐户用户。
- 使用外部用户身份创建外部帐户用户。
1。使用外部电子邮件地址创建本地帐户用户
使用 Azure AD Graph API,您可以 create a local account user,使用 用户 signInNames 属性 对象被设置为外部用户的电子邮件地址:
{
"accountEnabled": false,
"creationType": "LocalAccount",
"displayName": "John Smith",
"passwordProfile": {
"password": "a-strong-random-password",
"forceChangePasswordNextLogin": false
}
"signInNames": [
{
"type": "emailAddress",
"value": "john.smith@company.com"
}
]
}
注意:我推荐user对象的accountEnabled属性设置为true,这样终端用户就无法使用本地账号密码登录了。
使用自定义策略,您可以添加新的逻辑来查找使用外部电子邮件地址的本地帐户用户,并将外部用户身份添加到此本地帐户用户,例如:
...
<!--
Find the external account user using the external user identity.
-->
<OrchestrationStep Order="16" 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>
<!--
If the external account user hasn't been found, then find the local account user using the external email address.
-->
<OrchestrationStep Order="17" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserReadUsingEmailAddress" TechnicalProfileReferenceId="AAD-UserReadUsingEmailAddress-NoError" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If an account user hasn't been found, then create an external account user with the external user identity.
-->
<OrchestrationStep Order="18" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If the local account user has been found using the external email address, then add the external user identity to this local account user.
-->
<OrchestrationStep Order="19" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserWriteUsingAlternativeSecurityId technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>newUserCreated</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserReadUsingEmailAddress-NoError technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="false">
<Value>existingUserFoundByEmail</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUserIdentity" TechnicalProfileReferenceId="AAD-UserWriteUserIdentity" />
</ClaimsExchanges>
</OrchestrationStep>
...
2。使用外部用户身份创建外部帐户用户
使用 Azure AD Graph API,您可以 create an external account user,使用 user[的 userIdentities 属性 对象被设置为外部用户的对象标识符:
{
"accountEnabled": false,
"displayName": "John Smith",
"mailNickname": "john.smith",
"otherMails": [
"john.smith@company.com"
],
"userIdentities": [
{
"issuer": "https://sts.windows.net/{their-tenant-object-id}/",
"issuerUserId": "{their-user-object-id}"
}
],
"userPrincipalName": "{guid}@{your-tenant-name}.onmicrosoft.com"
}
其中 issuerUserId 必须设置为外部用户对象标识符的 base64 编码。
注意: 在 Azure AD OpenID Connect 技术配置文件中,您可能必须更改 socialIdpUserId 声明的声明映射sub claim to the oid claim, 所以它匹配 userIdentities.issuerUserId 属性 用户 对象:
<OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="oid" />
我正在构建一个载入网络应用程序来为我的 LOB 应用程序配置用户。我的大多数客户都是 "business customers",这意味着他们通常会被自定义策略定向到 v1 公共端点,从而允许他们针对自己的 AAD 租户进行身份验证。挑战在于新用户也需要在 LOB 应用程序中进行后续配置(创建数据库用户、分配一些权限等)。
作为入职的一部分,我想做的是调用 graphAPI 来创建将成为 b2c 中的联合用户帐户的内容,然后使用返回的新用户 objectId 处理特定于我的后续设置LOB 应用程序。理想情况下,当用户第一次到达时,他们将被重定向到针对他们自己的 AAD 的身份验证,然后映射到 b2c 中预先创建的用户,最后登陆具有已配置和准备好的 objectId 的 LOB 应用程序。
这是对自定义策略和 graphAPI 进行一些创造性使用的受支持方案吗?
谢谢 马克
您有以下选择:
- 使用外部电子邮件地址和 link 使用此本地帐户用户的外部用户身份创建本地帐户用户。
- 使用外部用户身份创建外部帐户用户。
1。使用外部电子邮件地址创建本地帐户用户
使用 Azure AD Graph API,您可以 create a local account user,使用 用户 signInNames 属性 对象被设置为外部用户的电子邮件地址:
{
"accountEnabled": false,
"creationType": "LocalAccount",
"displayName": "John Smith",
"passwordProfile": {
"password": "a-strong-random-password",
"forceChangePasswordNextLogin": false
}
"signInNames": [
{
"type": "emailAddress",
"value": "john.smith@company.com"
}
]
}
注意:我推荐user对象的accountEnabled属性设置为true,这样终端用户就无法使用本地账号密码登录了。
使用自定义策略,您可以添加新的逻辑来查找使用外部电子邮件地址的本地帐户用户,并将外部用户身份添加到此本地帐户用户,例如:
...
<!--
Find the external account user using the external user identity.
-->
<OrchestrationStep Order="16" 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>
<!--
If the external account user hasn't been found, then find the local account user using the external email address.
-->
<OrchestrationStep Order="17" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserReadUsingEmailAddress" TechnicalProfileReferenceId="AAD-UserReadUsingEmailAddress-NoError" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If an account user hasn't been found, then create an external account user with the external user identity.
-->
<OrchestrationStep Order="18" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If the local account user has been found using the external email address, then add the external user identity to this local account user.
-->
<OrchestrationStep Order="19" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserWriteUsingAlternativeSecurityId technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>newUserCreated</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserReadUsingEmailAddress-NoError technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="false">
<Value>existingUserFoundByEmail</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUserIdentity" TechnicalProfileReferenceId="AAD-UserWriteUserIdentity" />
</ClaimsExchanges>
</OrchestrationStep>
...
2。使用外部用户身份创建外部帐户用户
使用 Azure AD Graph API,您可以 create an external account user,使用 user[的 userIdentities 属性 对象被设置为外部用户的对象标识符:
{
"accountEnabled": false,
"displayName": "John Smith",
"mailNickname": "john.smith",
"otherMails": [
"john.smith@company.com"
],
"userIdentities": [
{
"issuer": "https://sts.windows.net/{their-tenant-object-id}/",
"issuerUserId": "{their-user-object-id}"
}
],
"userPrincipalName": "{guid}@{your-tenant-name}.onmicrosoft.com"
}
其中 issuerUserId 必须设置为外部用户对象标识符的 base64 编码。
注意: 在 Azure AD OpenID Connect 技术配置文件中,您可能必须更改 socialIdpUserId 声明的声明映射sub claim to the oid claim, 所以它匹配 userIdentities.issuerUserId 属性 用户 对象:
<OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="oid" />