如何使用' mail'创建一个微软的Azure广告用户?通过azure或统一图表apis填充?

时间:2016-07-13 23:15:00

标签: microsoft-graph azure-ad-graph-api

我正在尝试使用graph.microsoft.com或graph.windows.net apis中的创建端点为用户填充azure活动目录。

我遇到的问题是我无法填写邮件'属性;有没有办法创建用户或更新用户有电子邮件?

POST /beta/myorganization/users HTTP/1.1
Content-Type: application/json
Host: graph.microsoft.com
Connection: close
{
  "accountEnabled": true,
  "displayName": "Ham Sandwhich",
  "mailNickname": "test-ad-1-1",
  "passwordProfile": {
    "password": "allthegoodthings"
  },
  "userPrincipalName": "test-ad-1-1@orgname.onmicrosoft.com"
}

回应
HTTP/1.1 400 Bad Request
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json
Server: Microsoft-IIS/8.5
request-id: c954b6f0-9ac1-4354-b27d-88b0d89becfb
client-request-id: c954b6f0-9ac1-4354-b27d-88b0d89becfb
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US","Slice":"SliceB","ScaleUnit":"000","Host":"AGSFE_IN_4","ADSiteName":"WST"}}
Duration: 175.0114
X-Powered-By: ASP.NET
Date: Wed, 13 Jul 2016 23:12:28 GMT
Connection: close

{
  "error": {
    "code": "Request_BadRequest",
    "message": "Property 'mail' is read-only and cannot be set.",
    "innerError": {
      "request-id": "c954b6f0-9ac1-4354-b27d-88b0d89becfb",
      "date": "2016-07-13T23:12:28"
    }
  }
}

谢谢!

1 个答案:

答案 0 :(得分:1)

根据回复,你不能。另一种方法是设置字段otherMails

{
  "accountEnabled": true,
  "displayName": "Gabriel Ferrarini",
  "mailNickname": "GabrielFerrarini",
  "passwordProfile": {
    "password": "Test1234",
    "forceChangePasswordNextLogin": false
  },
  "otherMails": [
        "myemail@myhost.com"
      ],
  "userPrincipalName": "GabrielFerrarini@mytenant.onmicrosoft.com"
}