MS Entra – Users – License Details

Estimated reading: 5 minutes

MS Entra – Users – License Details

Get license details for a user.

Action details

PropertyValue
Action labelMS Entra – Users – License Details
CategoryCloudTools
Apex class and methodEntraLicenseDetails.getLicenseDetails
Input typeEntraLicenseDetails.EntraLicenseDetailsInput
Output typeList<EntraLicenseDetails.EntraLicenseDetailsOutput>
AuthorizationDelegated access only for license details.
Microsoft Graph requestGET /users/{userIdOrPrincipalName}/licenseDetails

Prerequisites and permissions

Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete sign-in for OAuth Delegated (Authorization Code). For supported OAuth Application (Client Credentials) requests, grant application permissions and administrator consent. The identity must have access to the selected resource; directory operations can also require Microsoft Entra roles. Use Creating an Entra ID App and Integration Connectors for setup.

The action permission provider declares these alternatives. They are not cumulative requirements or universally interchangeable; check the Microsoft reference for endpoint, target, and property restrictions.

Permission typeDeclared alternatives
DelegatedLicenseAssignment.Read.All, AgentIdUser.ReadWrite.All, AgentIdUser.ReadWrite.IdentityParentedBy, Directory.Read.All, Directory.ReadWrite.All, User.Read, User.Read.All, User.ReadWrite.All
ApplicationNot supported by the linked Microsoft reference.

Endpoints: /users/{userIdOrPrincipalName}/licenseDetails. Application permissions are not supported by the linked Microsoft operation reference.

See the Microsoft operation and permissions reference.

Inputs

InputApex fieldTypeRequiredDescription
User Id or Principal NameuserIdOrPrincipalNameStringYesUser id or user principal name to query

Supply a nonempty list with a non-null first request. Graph actions process only that first request. Global inputs do not expose connectorId; subscriber Apex and Flow use CloudTools connector selection. Use Microsoft Graph resource IDs or the specifically documented user identifier, and resolve dynamic values before invocation.

Outputs

Returns one mapped EntraLicenseDetailsOutput inside a list. Check the actual result shape and fields before use. This implementation creates a default result object when the response is null; an object alone does not prove that a resource was returned.

OutputApex fieldTypeDescription
OData ContextodataContextStringOData context value
Graph TipsgraphTipsStringGraph tips value

Behavior and limits

License detail endpoints require delegated access according to the Microsoft reference. Application authentication and consent do not make this endpoint support application access.

The response wrapper has a public value collection of public LicenseDetail models. It is not a global invocable output field and is not a subscriber Apex contract. The global outputs expose only OData Context and Graph Tips. Prefer the documented global collection models where appropriate.

Use in Flow

This endpoint requires delegated access, which CloudTools Flow automation does not support. Use a delegated custom integration for this operation.

Use in custom Apex

This subscriber-org example uses the Apptigent namespace. Replace identifiers and example values before use. Configure the connector, complete authorization first, run in a context permitting callouts, and handle exceptions, empty results, and unmapped fields.

Apptigent.EntraLicenseDetails.EntraLicenseDetailsInput request =
    new Apptigent.EntraLicenseDetails.EntraLicenseDetailsInput();
request.userIdOrPrincipalName = '87d349ed-44d7-43e1-9a83-5f2406dee5bd';



List<Apptigent.EntraLicenseDetails.EntraLicenseDetailsOutput> results =
    Apptigent.EntraLicenseDetails.getLicenseDetails(
        new List<Apptigent.EntraLicenseDetails.EntraLicenseDetailsInput>{ request }
    );
System.debug(results);

Use in a Lightning Web Component

Use getEntraLicenseDetails from msEntraConnectorLib through MSEntraConnectorController. These c/ imports apply in the same namespace. Set request.connectorId for direct MSEntraAction calls. The controller captures the request selection for MSEntraAction.

Global inputLWC request mapping
userIdOrPrincipalNamerequest.userIdOrPrincipalName

entraActionExample.js

import { LightningElement } from 'lwc';
import { getEntraLicenseDetails } from 'c/msEntraConnectorLib';

export default class EntraActionExample extends LightningElement {
    result = null;
    errorMessage = '';
    isRunning = false;
    completed = false;

    async handleRun() {
        if (this.isRunning || this.completed) return;
        this.isRunning = true;
        this.errorMessage = '';
        try {
            const request = { connectorId: 'REPLACE_WITH_CONNECTOR_RECORD_ID' };
            request.userIdOrPrincipalName = '87d349ed-44d7-43e1-9a83-5f2406dee5bd';
            this.result = await getEntraLicenseDetails(request);
            this.completed = true;
        } catch (error) {
            this.errorMessage = error.requiresInteractiveAuthorization
                ? 'Sign in to Microsoft for the connector, then try again.'
                : error.message || 'The Entra action failed.';
        } finally {
            this.isRunning = false;
        }
    }
}

entraActionExample.html

<template>
    <lightning-button label="Run action" onclick={handleRun}
        disabled={isRunning}></lightning-button>
    <p role="alert">{errorMessage}</p>
</template>

The library returns an array of mapped DTOs. The controller can flatten nested fields, serialize data, or map an action result into an operation DTO. rawJson contains serialized mapped Apex data rather than the untouched Graph response.

License DTOs depend on the global wrapper/model mapping. The legacy response wrapper and the detail item model are distinct; an empty or default DTO should not be taken as proof that the user has no licenses.

Use getMSEntraAuthorizationState, beginMSEntraAuthorization, and createMSEntraOAuthMessageHandler to arrange delegated sign-in. The library normalizes errors but does not automatically sign in or retry. Reset completed for a new deliberate operation, and inspect resource state before retrying a mutation with an uncertain outcome.

Error handling and troubleshooting

SymptomWhat to check
Required fields errorSupply a nonempty request list and required or conditionally required inputs. For LWC, use the mapped field names.
Authorization or access deniedCheck connector selection, sign-in, endpoint/target permission support, administrator consent, directory roles, and resource access.
Resource not foundCheck Microsoft IDs and parent resource relationships. Preserve group/drive/item associations and mailbox/calendar/event IDs.
Missing or unexpected outputCheck query support, pagination, wrapper versus item models, public-only properties, and mapped DTO fields.
Operation rejectedInspect the Microsoft error, supported writable fields, group/calendar restrictions, recipient/license data, and file transfer limits.

See Entra connector introduction.

Share this Doc

MS Entra – Users – License Details

Or copy link

CONTENTS

Free eBook: The Ultimate Guide to Power Platform Custom Connectors

Antimanual

Ask our AI support assistant your questions about our platform, features, and services.

You are offline
Chatbot avatar
What can I help you with?

Subscribe

×
Cancel