英文:
Not able to create users using identities in Azure AD B2C using Microsoft Graph API
问题
我正在尝试使用标识在Azure AD B2C中创建本地帐户(例如abc@yahoo.com)。
以下是请求有效载荷:
{
"displayName": "John Smith",
"identities": [
{
"signInType": "emailAddress",
"issuer": "mytenant.onmicrosoft.com",
"issuerAssignedId": "jsmith@yopmail.com"
}
],
"passwordProfile": {
"password": "Welcome@1",
"forceChangePasswordNextSignIn": false
},
"passwordPolicies": "DisablePasswordExpiration"
}
这是我收到的响应:
"error": {
"code": "Request_BadRequest",
"message": "Property userPrincipalName value is required but is empty or missing."
}
起初,它对accountEnabled
和mailNickname
抛出错误,所以我在有效载荷中添加了它们,然后它对userPrincipalName
抛出错误。
如果我在有效载荷中添加userPrincipalName
,它会抛出以下错误:
{
"code": "Request_BadRequest",
"message": "Property creationType is invalid."
}
如何使用Microsoft Graph API在Azure AD B2C中使用标识创建用户?
英文:
I'm trying to create local account (like abc@yahoo.com) in Azure AD B2C using identities.
This is the document I followed:
https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http#example-2-create-a-user-with-social-and-local-account-identities.
Below is the request payload:
{
"displayName": "John Smith",
"identities": [
{
"signInType": "emailAddress",
"issuer": "mytenant.onmicrosoft.com",
"issuerAssignedId": "jsmith@yopmail.com"
}
],
"passwordProfile": {
"password": "Welcome@1",
"forceChangePasswordNextSignIn": false
},
"passwordPolicies": "DisablePasswordExpiration"
}
This is the response I'm getting:
"error": {
"code": "Request_BadRequest",
"message": "Property userPrincipalName value is required but is empty or missing."
}
First it was throwing an error for accountEnabled
, mailNickname
, so added them in payload, then it was throwing an error for userPrincipalName
.
If I add userPrincipalName
in the payload, it was throwing an error like this:
{
"code": "Request_BadRequest",
"message": "Property creationType is invalid."
}
How can I create users using identities in Azure AD B2C using Microsoft Graph API?
答案1
得分: 0
这是一个适用于我所有租户的属性示例:
{
"accountEnabled": true,
"displayName": "测试用户",
"mailNickname": "TestU",
"userPrincipalName": "TestU@tenant.onmicrosoft.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "xWwvJ]6NMw+bWH-d"
}
}
使用类似这样的内容,您是否仍然遇到错误?
更新
对于多个身份,可以使用以下内容:
"identities": [
{
"signInType": "userName",
"issuer": "contoso.onmicrosoft.com",
"issuerAssignedId": "johnsmith"
},
{
"signInType": "emailAddress",
"issuer": "contoso.onmicrosoft.com",
"issuerAssignedId": "jsmith@yahoo.com"
},
{
"signInType": "federated",
"issuer": "facebook.com",
"issuerAssignedId": "5eecb0cd"
}
]
英文:
This is an example of attributes that work across all my tenants:
{
"accountEnabled": true,
"displayName": "Test User",
"mailNickname": "TestU",
"userPrincipalName": "TestU@tenant.onmicrosoft.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "xWwvJ]6NMw+bWH-d"
}
}
Do you still get the error with something like this?
Update
For multiple identities, something like this works:
"identities": [
{
"signInType": "userName",
"issuer": "contoso.onmicrosoft.com",
"issuerAssignedId": "johnsmith"
},
{
"signInType": "emailAddress",
"issuer": "contoso.onmicrosoft.com",
"issuerAssignedId": "jsmith@yahoo.com"
},
{
"signInType": "federated",
"issuer": "facebook.com",
"issuerAssignedId": "5eecb0cd"
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论