2017-09-08 54 views
0

我使用Microsoft Graph API PHP SDK在Azure Active Directory B2C中添加用户。我设法创建了一个用户userPrincipalName,如[email protected]在Azure AD B2C(gmail等)中为其他邮件提供商创建用户

我无法添加具有GMail地址的用户,例如[email protected]

我试图添加signInNames集合,但我得到了以下回应:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: 
POST https://graph.microsoft.com/v1.0/users resulted in a 400 Bad Request 
response: 
    { "error": { 
     "code": "Request_BadRequest", 
     "message": "Invalid property 'signInNames'.", 
     "innerError": (truncated...) 

这里是我的JSON请求体:

{ 
    "accountEnabled": true, 
    "displayName": "John Doe", 
    "userPrincipalName": "[email protected]", 
    "creationType": "LocalAccount", 
    "passwordProfile" : { 
     "forceChangePasswordNextSignIn": true, 
     "password": "[email protected]!ssWor?D" 
    }, 
    "signInNames": [ 
     { 
      "type": "emailAddress", 
      "value": "[email protected]" 
     } 
    ] 
} 
+0

[尚不支持,请参阅此SO帖子,使用AAD图形API](https://stackoverflow.com/questions/43770376/which-graph-api-should-be-used-with-azure-ad-b2c ):'https:// graph.windows.net' – spottedmahn

+0

我认为这个函数是在7月份的1.6版本中添加的。 请参阅https://msdn.microsoft.com/fr-fr/library/azure/ad/graph/api/users-operations(章节“创建用户(本地帐户)”) – Aldwen

+0

我怀疑这适用于AAD而不是B2C – spottedmahn

回答

2

你与Azure AD Graph API混淆Microsoft Graph API。这是两种不同的API。虽然它们共享很多功能,但对这些API的调用是不可互换的。

Microsoft Graph API中的User object不支持signInNames属性。这就是它返回错误的原因。

目前本地帐户用户不受Microsoft Graph API支持。

+1

你是对的!我是个白痴......非常感谢你。 – Aldwen