ユーザーに割り当てられたライセンスをライセンス グループ別に取得する
指定したライセンス グループのユーザー割り当てライセンスの一覧を取得する方法。
前提条件
パートナー センターの認証に関するページで説明している資格情報。 このシナリオでは、アプリとユーザーの資格情報を使用した認証のみがサポートされます。
顧客 ID です (
customer-tenant-id
)。 顧客の ID がわからない場合は、[顧客] ワークスペースを選択し、顧客の一覧から顧客を選択し、[アカウント] を選択して、パートナー センターで検索できます。 顧客の [アカウント] ページで、[顧客アカウント情報] セクションで Microsoft ID を探します。 Microsoft ID は、顧客 ID (customer-tenant-id
) と同じです。ユーザー識別子。
1 つ以上のライセンス グループ識別子の一覧。
GDAP ロール
次の GDAP ロールのうち少なくとも 1 つが必要です。
- ディレクトリ閲覧者
- ライセンス管理者
- ユーザー管理者
- ディレクトリ ライター
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 パラメーター
次のパスとクエリ パラメーターを使用して、顧客、ユーザー、ライセンス グループを識別します。
名前 | タイプ | Required | 説明 |
---|---|---|---|
customer-id | string | はい | 顧客を識別する GUID 形式の文字列。 |
user-id | string | はい | ユーザーを識別する GUID 形式の文字列。 |
licenseGroupIds | string | いいえ | 割り当てられたライセンスのライセンス グループを示す列挙値。 有効な値: Group1、Group2 Group1 - このグループには、Microsoft Entra ID でライセンスを管理できるすべての製品があります。 Group2 - このグループには Minecraft 製品ライセンスしかありません。 |
要求ヘッダー
詳細については、「パートナー センター 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 の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示