如何创建通过 azure 或统一图形 api 填充 'mail' 的 Microsoft azure 广告用户?

How can I create a microsoft azure ad user with 'mail' populated through azure or unified graph apis?

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

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

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"
    }
  }
}

谢谢!

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

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