Get Microsoft 365 properties

Retrieves the status of a user's Microsoft 365 account and all licenses that are assigned or can be assigned to that user.

GET ~/api/directoryObjects/o365Account/properties?<parameters>

Query parameters

  • Name

  • Required

  • Type

  • Description

  • directoryObject

  • True

  • string

  • The identifier of the user whose Microsoft 365 properties to retrieve. You can use:

     Distinguished name (DN)
    # Example
    CN=John Smith,CN=Users,DC=example,DC=com
    
     Globally unique identifier (GUID)
    # Example
    7a4267ce-d354-44e7-8bd6-c681f1284a41
    
     Security identifier (SID)
    # Example
    S-1-5-21-3635565734-1729062999-1822655016-1627
    

Request headers

  • Name

  • Required

  • Description

  • Adm-Authorization

  • True

  • Specify the security token obtained during authentication.

Request body

Do not send a body with this request.

Responses

If successful, returns 200 OK status code and Microsoft 365 properties in the response body. Otherwise, returns one of the common HTTP error codes and an error description in the response body.

Microsoft 365 properties is a JSON object with the following data structure:

{
    "isCreated": <true|false>,
    "locationName": "<location>",
    "signInBlocked": <true|false>,
    "lastDirSyncTimeUtc": "<lastDirSyncTimeUtc>",
    "licenses": [
        {
            "assigned": <true|false>,
            "consumedUnits": <integer>,
            "totalUnits": <integer>,
            "sku": {
                "skuPartNumber": "<skuPartNumber>",
                "displayName": "<displayName>",
                "isUnavailable": <true|false>,
                "services": [
                    {
                        "serviceName": "<serviceName>",
                        "serviceDisplayName": "<serviceDisplayName>",
                        "enabled": <true|false>,
                        "isAutoAssignable": <true|false>
                    },
                    ...
                ]
            }
        },
        ...
    ]
}

isCreated bool

Equals true if the user has a Microsoft 365 account.


locationName string

A two-letter country code (ISO 3166-1 alpha-2) that represents the user's location in Microsoft 365. If the user doesn't have a Microsoft 365 account, equals null.


signInBlocked bool

Equals true if the user is not allowed to sign in to Microsoft 365. If the user is allowed to sign in or doesn't have a Microsoft 365 account, equals false.


lastDirSyncTimeUtc string

The UTC date and time the user's account was last synchronized via Microsoft Entra Connect, in the ISO 8601 format (e.g. 2023-03-27T10:28:14Z). Equals null if the user is not synchronized.


licenses M365LicenseInfo array

The information about the licenses assigned to the user and all available licenses in the user's Microsoft 365 tenant.

 Show attributes

licenses.sku M365SkuInfo array

Detailed information about a Microsoft 365 license.

 Show attributes

licenses.sku.skuPartNumber string

The SKU part number of the license.


licenses.sku.displayName string

The license display name in Adaxes.


licenses.sku.isUnavailable bool

Always equals false.


licenses.sku.services M365ServiceInfo array

Detailed information about the services within this license.

 Show attributes

licenses.sku.services.serviceName string

The SKU part number of the service.


licenses.sku.services.serviceDisplayName string

The service display name in Adaxes.


licenses.sku.services.enabled bool

Equals true if this service is enabled for the user.


licenses.sku.services.isAutoAssignable bool

Equals true if this service is automatically assigned with the license and cannot be revoked without revoking the license.


licenses.assigned bool

Equals true if this license is assigned to the user.


licenses.consumedUnits integer

The number of licenses of this type assigned to users in this Microsoft 365 tenant.


licenses.totalUnits integer

The total number of purchased licenses of this type.


Example

 Retrieve Microsoft 365 properties of a user

The following code sample retrieves the Microsoft 365 properties of a user.

Request

PowerShell
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/o365Account/properties"

# Request parameters
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}
$queryParams = @{"directoryObject" = "CN=John Smith,CN=Users,DC=example,DC=com"}

# Make request
Invoke-RestMethod -Method GET -Headers $requestHeaders -Uri $requestUrl -Body $queryParams
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        const string baseUrl = "https://host.example.com/restApi";
        const string endpoint = "/api/directoryObjects/o365Account/properties";

        // Request parameters
        const string userIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com";
        UriBuilder requestUrl = new()
        {
            Host = baseUrl + endpoint,
            Query = $"?directoryObject={userIdentifier}"
        };

        // Initialize HTTP client
        using HttpClient client = new();
        client.DefaultRequestHeaders.Add("Adm-Authorization", YOUR-SECURITY-TOKEN);

        // Make request
        string response = await client.GetStringAsync(requestUrl.ToString());
        Console.WriteLine(response);
    }
}

cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--get -X GET 'https://host.example.com/restApi/api/directoryObjects/o365Account/properties' \
--data-urlencode 'directoryobject=CN=John Smith,CN=Users,DC=example,DC=com'
node.js
var https = require('https');

// Request parameters
var userIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com";
var requestPath = "/api/directoryObjects/o365Account/properties"
    + `?directoryobject=${userIdentifier}`;

var options = {
    'method': 'GET',
    'hostname': 'host.example.com/restApi',
    'path': encodeURI(requestPath),
    'headers': {'Adm-Authorization': 'YOUR-SECURITY-TOKEN'}
};

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.end();

Python
import requests
import json

baseUrl = "https://host.example.com/restApi"
endpoint = "/api/directoryObjects/o365Account/properties"

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
queryParams = {"directoryObject": "CN=John Smith,CN=Users,DC=example,DC=com"}

# Make request
request = requests.get(requestUrl, headers=requestHeaders, params=queryParams)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

{
    "locationName": "GB",
    "signInBlocked": false,
    "licenses": [
        {
            "sku": {
                "skuPartNumber": "SPE_E5",
                "displayName": "Microsoft 365 E5",
                "isUnavailable": false,
                "services": [
                    {
                        "serviceName": "ME-ID_PREMIUM",
                        "serviceDisplayName": "Microsoft Entra ID P1",
                        "enabled": true,
                        "isAutoAssignable": false
                    },
                    {
                        "serviceName": "ME-ID_PREMIUM_P2",
                        "serviceDisplayName": "Microsoft Entra ID P2",
                        "enabled": true,
                        "isAutoAssignable": false
                    },
                    ...
                ]
            },
            "assigned": true,
            "consumedUnits": 2387,
            "totalUnits": 2500
        },
        {
            "sku": {
                "skuPartNumber": "FLOW_FREE",
                "displayName": "Microsoft Flow Free",
                "isUnavailable": false,
                "services": [
                    {
                        "serviceName": "FLOW_P2_VIRAL",
                        "serviceDisplayName": "Flow Free",
                        "enabled": true,
                        "isAutoAssignable": false
                    }
                ]
            },
            "assigned": false,
            "consumedUnits": 4543,
            "totalUnits": 5000
        }
    ],
    "isCreated": true,
    "lastDirSyncTimeUtc": null
}

See also