Get licenses assigned to a user within a customer account
This article describes how to get a list of licenses assigned to a user within a customer account.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with App+User credentials only.
A customer ID (
customer-tenant-id
). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer's Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id
).A user identifier.
GDAP roles
You'll need at least one of the following GDAP roles:
- Directory Reader
- License Administrator
- User Administrator
- Directory Writers
C#
To check which licenses are assigned to a user from the default group1 license group, first use the IAggregatePartner.Customers.ById method with the customer ID to identify the customer. Then call the Users.ById method with the user ID to identify the user. Next, get an interface to customer user license operations from the Licenses property. Finally, call the Get or the GetAsync method to retrieve the collection of licenses assigned to the user.
// string selectedCustomerUserId;
// string selectedCustomerId;
// IAggregatePartner partnerOperations;
var customerUserAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get();
Sample: Console test app. Project: Partner Center SDK Samples Class: CustomerUserAssignedLicenses.cs
REST request
Request syntax
Method | Request URI |
---|---|
GET | {baseURL}/v1/customers/{customer-id}/users/{user-id}/licenses HTTP/1.1 |
URI parameter
Use the following path parameters to identify the customer and user.
Name | Type | Required | Description |
---|---|---|---|
customer-id | string | Yes | A GUID formatted string that identifies the customer. |
user-id | string | Yes | A GUID formatted string that identifies the user. |
Request headers
For more information, see Partner Center REST headers.
Request body
None.
Request example
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: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com
REST response
If successful, the response body contains the collection of License resources.
Response success and error codes
Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center error codes.
Response example
HTTP/1.1 200 OK
Content-Length: 3883
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
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"
}
}