group:assignLicense

命名空间:microsoft.graph

添加或删除组上的许可证。 分配给组的许可证将分配给组中的所有用户。 若要详细了解基于组的许可,请参阅Azure Active Directory中基于组的许可

若要获取目录中可用的订阅,请执行 GET subscribedSkus 请求

权限

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) Group.ReadWrite.All, Directory.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。
应用程序 Group.ReadWrite.All、Directory.ReadWrite.All

HTTP 请求

POST /groups/{id}/assignLicense

请求标头

标头
Authorization Bearer {token}。必需。
Content-Type application/json. Required.

请求正文

在请求正文中,提供具有以下参数的 JSON 对象。

参数 类型 说明
addLicenses assignedLicense collection 用于指定要添加的许可证的 assignedLicense 对象集合。 可以通过在 assignedLicense 对象上设置 disabledPlans 属性来禁用与许可证关联的 servicePlans
removeLicenses Guid 集合 标识要删除的许可证的 skuId 的集合。

响应

如果成功,此方法在响应正文中返回 202 Accepted 响应代码和目标 对象。

示例

示例 1:向组添加许可证

以下示例将许可证添加到组。

请求

POST https://graph.microsoft.com/v1.0/groups/1132b215-826f-42a9-8cfe-1643d19d17fd/assignLicense
Content-type: application/json

{
  "addLicenses": [
    {
      "disabledPlans": [
        "113feb6c-3fe4-4440-bddc-54d774bf0318",
        "14ab5db5-e6c4-4b20-b4bc-13e36fd2227f"
      ],
      "skuId": "b05e124f-c7cc-45a0-a6aa-8cf78c946968"
    },
    {
      "disabledPlans": [
        "a413a9ff-720c-4822-98ef-2f37c2a21f4c"
      ],
      "skuId": "c7df2760-2c81-4ef7-b578-5b5392b571df"
    }
  ],
  "removeLicenses": []
}

响应

响应是更新后的组对象。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 202 Accepted
Content-type: application/json
location: https://graph.microsoft.com/v2/e8e96c2a-d787-4eb1-98d7-9e57c965f1de/directoryObjects/1132b215-826f-42a9-8cfe-1643d19d17fd/Microsoft.DirectoryServices.Group

{
  "id": "1132b215-826f-42a9-8cfe-1643d19d17fd",
  "createdDateTime": "2021-03-12T11:15:03Z",
  "groupTypes": [],
  "securityEnabled": true,
}

示例 2:从组中删除许可证

以下示例从组中删除许可证。

请求

POST https://graph.microsoft.com/v1.0/groups/1132b215-826f-42a9-8cfe-1643d19d17fd/assignLicense
Content-type: application/json

{
  "addLicenses": [],
  "removeLicenses": [
    "c7df2760-2c81-4ef7-b578-5b5392b571df",
    "b05e124f-c7cc-45a0-a6aa-8cf78c946968"
  ]
}

响应

响应是更新后的组对象。

注意: 此处显示的响应对象可能会缩短可读性。

HTTP/1.1 202 Accepted
Content-type: application/json
location: https://graph.microsoft.com/v2/d056d009-17b3-4106-8173-cd3978ada898/directoryObjects/1ad75eeb-7e5a-4367-a493-9214d90d54d0/Microsoft.DirectoryServices.Group


{
  "id": "1ad75eeb-7e5a-4367-a493-9214d90d54d0",
  "deletedDateTime": null,
  "classification": null,
  "createdDateTime": "2018-04-18T22:05:03Z",
  "securityEnabled": true,

}