按许可证组获取分配给用户的许可证
如何获取指定许可证组的用户分配许可证的列表。
先决条件
合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。
客户 ID (
customer-tenant-id
)。 如果不知道客户的 ID,可以通过选择“客户”工作区,然后从客户列表中选择客户,然后选择“帐户”,在合作伙伴中心中查找该 ID。 在客户的“帐户”页上,在“客户帐户信息”部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id
) 相同。一个用户标识符。
一个或多个许可证组标识符的列表。
GDAP 角色
至少需要以下 GDAP 角色之一:
- 目录读取者
- 许可证管理员
- 用户管理员
- 目录编写人员
C#
若要检查从指定许可证组分配给用户的许可证,请首先实例化 LicenseGroupId 类型的 [List/dotnet/api/system.collections.generic.list-1),然后将许可证组添加到列表中。 然后,使用具有客户 ID 的 IAggregatePartner.Customers.ById 方法来标识客户。 接下来,使用用户 ID 调用 Users.ById 方法以标识用户。 然后,从 Licenses 属性获取客户用户许可证操作的界面。 最后,将许可证组列表传递给 Get 或 GetAsync 方法,以检索分配给用户的许可证集合。
// string selectedCustomerUserId;
// string selectedCustomerId;
// IAggregatePartner partnerOperations;
// To get the group1 (Azure Active Directory (AAD)) assigned licenses.
List<LicenseGroupId> licenseGroupIds = new List<LicenseGroupId>(){ LicenseGroupId.Group1 };
var customerUserAadAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get(licenseGroupIds);
// To get the group2 (Minecraft) assigned licenses.
List<LicenseGroupId> licenseGroupIds = new List<LicenseGroupId>(){ LicenseGroupId.Group2 };
var customerUserSfbAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get(licenseGroupIds);
// To get both AAD and Minecraft assigned licenses.
List<LicenseGroupId> licenseGroupIds = new List<LicenseGroupId>(){ LicenseGroupId.Group1, LicenseGroupId.Group2 };
var customerUserBothAadAndSfbAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get(licenseGroupIds);
REST 请求
请求语法
方法 | 请求 URI |
---|---|
GET | {baseURL}/v1/customers/{customer-id}/users/{user-id}/licenses?licenseGroupIds=Group1 HTTP/1.1 |
GET | {baseURL}/v1/customers/{customer-id}/users/{user-id}/licenses?licenseGroupIds=Group2 HTTP/1.1 |
GET | {baseURL}/v1/customers/{customer-id}/users/{user-id}/licenses?licenseGroupIds=Group1&licenseGroupIds=Group2 HTTP/1.1 |
URI 参数
使用以下路径和查询参数来标识客户、用户和许可证组。
名称 | 类型 | 必需 | 说明 |
---|---|---|---|
customer-id | string | 是 | 标识客户的 GUID 格式字符串。 |
user-id | string | 是 | 标识用户的 GUID 格式字符串。 |
licenseGroupIds | string | 否 | 一个枚举值,指示已分配许可证的许可证组。 有效值:Group1、Group2 Group1 - 此组包含可在 Microsoft Entra ID 中管理其许可证的所有产品。 Group2 - 此组仅我的世界产品许可证。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
无。
请求示例
GET https://api.partnercenter.microsoft.com/v1/customers/0c39d6d5-c70d-4c55-bc02-f620844f3fd1/users/482e2152-4b49-48ec-b715-823365ce3d4c/licenses?licenseGroupIds=Group1&licenseGroupIds=Group2 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: a1d077e4-28b1-4578-b873-6d1a82fa1644
MS-CorrelationId: c8cb5a60-ae08-4afc-92f0-efc42adfa186
X-Locale: en-US
Host: api.partnercenter.microsoft.com
REST 响应
如果成功,响应正文将包含许可证资源的集合。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心错误代码。
响应示例
HTTP/1.1 200 OK
Content-Type: application/json
MS-CorrelationId: 8a53b025-d5be-4d98-ab20-229d1813de76
MS-RequestId: b1317092-f087-471e-a637-f66523b2b94c
Date: June 24 2016 22:00:25 PST
{
"totalCount": 2,
"items": [{
"servicePlans": [
],
"productSku": {
"id": "984df360-9a74-4647-8cf8-696749f6247a",
"name": "Minecraft Education Edition Faculty",
"skuPartNumber": "CFQ7TTC0K5DR/0002",
"licenseGroupId": "group2"
},
"attributes": {
"objectType": "License"
}
}, {
"servicePlans": [{
"displayName": "Windows Defender Advanced Threat Protection",
"serviceName": "WINDEFATP",
"id": "871d91ec-ec1a-452b-a83f-bd76c7d770ef",
"capabilityStatus": "Assigned",
"targetType": "User"
}, {
"displayName": "Windows 10 Enterprise E3",
"serviceName": "WIN10_PRO_ENT_SUB",
"id": "21b439ba-a0ca-424f-a6cc-52f954a5b111",
"capabilityStatus": "Assigned",
"targetType": "User"
}
],
"productSku": {
"id": "1e7e1070-8ccb-4aca-b470-d7cb538cb07e",
"name": "Windows 10 Enterprise E5",
"skuPartNumber": "WIN_ENT_E5",
"licenseGroupId": "group1"
},
"attributes": {
"objectType": "License"
}
}
],
"attributes": {
"objectType": "Collection"
}
}
响应示例(未找到匹配的许可证)
如果指定的许可证组找不到匹配的许可证,响应将包含一个空集合,其值为 0 的 totalCount 元素。
HTTP/1.1 200 OK
Content-Length: 71
Content-Type: application/json; charset=utf-8
MS-CorrelationId: c8cb5a60-ae08-4afc-92f0-efc42adfa186
MS-RequestId: a1d077e4-28b1-4578-b873-6d1a82fa1644
MS-CV: q05xrhUeDUKvhrFt.0
MS-ServerId: 030020525
Date: Fri, 09 Jun 2017 22:50:11 GMT
{
"totalCount": 0,
"items": [],
"attributes": {
"objectType": "Collection"
}
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈