获取分配给客户帐户中的用户的许可证

如何获取分配给客户帐户中的用户的许可证列表。 此处显示的示例返回从 group1 分配的许可证,即表示由 Microsoft Entra ID 管理的许可证的默认许可证组。 若要从指定许可证组获取分配的许可证,请参阅 按许可证组获取分配给用户的许可证。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以通过选择“客户”工作区,然后从客户列表中选择客户,然后选择“帐户”,在合作伙伴中心查找该 ID。 在客户的“帐户”页上,在“客户帐户信息”部分查找 Microsoft ID Microsoft ID 与客户 ID (customer-tenant-id) 相同。

  • 一个用户标识符。

C#

若要检查将哪些许可证分配给默认 group1 许可证组的用户,请先将 IAggregatePartner.Customers.ById 方法与客户 ID 一起使用来标识客户。 然后,使用用户 ID 调用 Users.ById 方法以标识用户。 接下来,从 Licenses 属性获取客户用户许可证操作的界面。 最后,调用 GetGetAsync 方法以检索分配给用户的许可证集合。

// string selectedCustomerUserId;
// string selectedCustomerId;
// IAggregatePartner partnerOperations;

var customerUserAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get();

示例控制台测试应用项目:合作伙伴中心 SDK 示例 :CustomerUserAssignedLicenses.cs

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/customers/{customer-id}/users/{user-id}/licenses HTTP/1.1

URI 参数

使用以下路径参数标识客户和用户。

名称 类型​​ 必需 说明
customer-id string 标识客户的 GUID 格式字符串。
user-id string 标识用户的 GUID 格式字符串。

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

无。

请求示例

GET https://api.partnercenter.microsoft.com/v1/customers/0c39d6d5-c70d-4c55-bc02-f620844f3fd1/users/482e2152-4b49-48ec-b715-823365ce3d4c/licenses HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 68e50b00-e1ff-422a-a293-158617463d41
MS-CorrelationId: 813f15b3-eb18-4709-b2f3-668d62babf91
X-Locale: en-US
Host: api.partnercenter.microsoft.com

REST 响应

如果成功,响应正文将包含许可证资源的集合

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心错误代码

响应示例

HTTP/1.1 200 OK
Content-Length: 3883
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 813f15b3-eb18-4709-b2f3-668d62babf91
MS-RequestId: 68e50b00-e1ff-422a-a293-158617463d41
MS-CV: WYkHYMfWTUajFosK.0
MS-ServerId: 020021921
Date: Fri, 09 Jun 2017 00:29:24 GMT

{
    "totalCount": 1,
    "items": [{
            "servicePlans": [{
                    "displayName": "Azure Information Protection Premium P1",
                    "serviceName": "RMS_S_PREMIUM",
                    "id": "6c57d4b6-3b23-47a5-9bc9-69f17b4947b3",
                    "capabilityStatus": "Assigned",
                    "targetType": "User"
                }, {
                    "displayName": "Microsoft Intune A Direct",
                    "serviceName": "INTUNE_A",
                    "id": "c1ec4a95-1f05-45b3-a911-aa3fa01094f5",
                    "capabilityStatus": "Assigned",
                    "targetType": "User"
                }, {
                    "displayName": "Microsoft Azure Active Directory Rights",
                    "serviceName": "RMS_S_ENTERPRISE",
                    "id": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90",
                    "capabilityStatus": "Assigned",
                    "targetType": "User"
                }, {
                    "displayName": "Azure Active Directory Premium P1",
                    "serviceName": "AAD_PREMIUM",
                    "id": "41781fb2-bc02-4b7c-bd55-b576c07bb09d",
                    "capabilityStatus": "Assigned",
                    "targetType": "User"
                }, {
                    "displayName": "Microsoft Azure Multifactor Authentication",
                    "serviceName": "MFA_PREMIUM",
                    "id": "8a256a2b-b617-496d-b51b-e76466e88db0",
                    "capabilityStatus": "Assigned",
                    "targetType": "User"
                }
            ],
            "productSku": {
                "id": "efccb6f7-5641-4e0e-bd10-b4976e1bf68e",
                "name": "Enterprise Mobility + Security E3",
                "skuPartNumber": "EMS",
                "licenseGroupId": "group1"
            },
            "attributes": {
                "objectType": "License"
            }
        }
    ],
    "attributes": {
        "objectType": "Collection"
    }
}