Get a user account by ID

Get a specific user account for a customer.

  • 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).

GDAP roles

You'll need at least one of the following GDAP roles:

  • Directory Reader
  • Global reader
  • User Administrator

C#

To retrieve a user account for a customer, call the IAggregatePartner.Customers.ById method with the customer ID to identify the customer. Next, call the Users.ById method to retrieve the specific user. Finally, call the Users.Get or GetAsync method to retrieve the user account.

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

// Get customer user detail.
var customerUsers = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Get();

Sample: Console test app. Project: Partner Center SDK Samples Class: GetCustomerUserDetails.cs

REST request

Request syntax

Method Request URI
GET {baseURL}/v1/customers/{customer-tenant-id}/users/{user-id} HTTP/1.1

URI parameter

Use the following URI parameters to identify the correct customer and user.

Name Type Required Description
customer-tenant-id guid Y The value is a GUID formatted customer-tenant-id that allows the reseller to filter the results for a given customer that belongs to the reseller.
user-id guid Y The value is a GUID formatted user-id that belongs to a single user account.

Request headers

For more information, see Partner Center REST headers.

Request body

None.

Request example

GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a9ef48bb-8758-4590-a312-d4a47bfaded4 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: c1f673cb-655c-45a7-8a6b-257a0a006f4b
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com

REST response

If successful, this method returns the user account for the customer.

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 REST error codes.

Response example

HTTP/1.1 200 OK
Content-Length: 432
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: c1f673cb-655c-45a7-8a6b-257a0a006f4b
MS-CV: uWM1EGU7+0aI2MvV.0
MS-ServerId: 020021921
Date: Wed, 21 Dec 2016 22:59:10 GMT

{
    "usageLocation": "US",
    "id": "a9ef48bb-8758-4590-a312-d4a47bfaded4",
    "userPrincipalName": "Daniel@dtdemocspcustomer005.onmicrosoft.com",
    "firstName": "Daniel",
    "lastName": "Tsai",
    "displayName": "Daniel Tsai",
    "userDomainType": "none",
    "state": "active",
    "links": {
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a9ef48bb-8758-4590-a312-d4a47bfaded4",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "CustomerUser"
    }
}