MS Entra – Users – Get User Groups

Estimated reading: 7 minutes

MS Entra – Users – Get User Groups

Get groups for a user in Entra ID.

Action details

PropertyValue
Action labelMS Entra – Users – Get User Groups
CategoryCloudTools
Apex class and methodGetEntraUserGroups.getUserGroups
Input typeGetEntraUserGroups.GetEntraUserGroupsInput
Output typeList<List<MSEntraGroup>>
AuthorizationMicrosoft 365 connector; supported authorization depends on the endpoint and target.
Microsoft Graph requestGET /users/{userIdOrPrincipalName}/memberOf/microsoft.graph.group

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, not all are least privileged, and a scope can have target-specific restrictions. Check the Microsoft operation reference before selecting permissions.

Permission typeDeclared alternatives
DelegatedUser.Read, User.Read.All, Directory.Read.All, Directory.ReadWrite.All, GroupMember.Read.All
ApplicationDirectory.Read.All, Directory.ReadWrite.All

Endpoints: /users/{id | userPrincipalName}/memberOf/microsoft.graph.group

See the Microsoft operation and permissions reference.

Inputs

InputApex fieldTypeRequiredDescription
User Id or Principal NameuserIdOrPrincipalNameStringYesUser id or principal name to query groups for
Filter QueryfilterQueryStringNoOData $filter query string
Select QueryselectQueryStringNoOData $select query string
Order By QueryorderbyQueryStringNoOData $orderby query string
Top QuerytopQueryStringNoOData $top query string

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 an outer list containing one resource collection. It is not one collection for every input request. A null response or unmapped value produces an empty inner collection.

OutputApex fieldTypeDescription
IdidStringUnique identifier for the group
OData TypeodataTypeStringOData type for the group
Deleted Date TimedeletedDateTimeStringDate and time when the group was deleted
Created Date TimecreatedDateTimeStringDate and time when the group was created
DescriptiondescriptionStringDescription for the group
Display NamedisplayNameStringDisplay name for the group
Expiration Date TimeexpirationDateTimeStringDate and time when the group is set to expire
Group TypesgroupTypesList<String>Group types (for example: Unified, DynamicMembership)
MailmailStringSMTP address for the group
Mail EnabledmailEnabledBooleanWhether the group is mail-enabled
Mail NicknamemailNicknameStringMail alias for the group
Membership RulemembershipRuleStringDynamic membership rule for the group
Membership Rule Processing StatemembershipRuleProcessingStateStringProcessing state of the dynamic membership rule
On-Premises Domain NameonPremisesDomainNameStringOn-premises domain name (if synced)
On-Premises Last Sync Date TimeonPremisesLastSyncDateTimeStringLast sync time with on-premises directory
On-Premises NetBios NameonPremisesNetBiosNameStringOn-premises NetBios name (if synced)
On-Premises Sam Account NameonPremisesSamAccountNameStringOn-premises SAM account name (if synced)
On-Premises Security IdentifieronPremisesSecurityIdentifierStringOn-premises security identifier (if synced)
On-Premises Sync EnabledonPremisesSyncEnabledBooleanWhether the group is synced from on-premises
Preferred Data LocationpreferredDataLocationStringPreferred data location for the group
Preferred LanguagepreferredLanguageStringPreferred language for the group
Proxy AddressesproxyAddressesList<String>Proxy addresses for the group
Renewed Date TimerenewedDateTimeStringDate and time when the group was last renewed
Security EnabledsecurityEnabledBooleanWhether the group is a security group
Security IdentifiersecurityIdentifierStringSecurity identifier for the group
VisibilityvisibilityStringGroup join policy and content visibility (Private, Public, HiddenMembership)
ClassificationclassificationStringClassification for the group
Is Assignable To RoleisAssignableToRoleBooleanWhether the group can be assigned to a role
ThemethemeStringMicrosoft 365 group theme
Unique NameuniqueNameStringUnique name for the group
Allow External SendersallowExternalSendersBooleanWhether external senders can email the group
Auto Subscribe New MembersautoSubscribeNewMembersBooleanWhether new members are auto-subscribed to email
Hide From Address ListshideFromAddressListsBooleanWhether the group is hidden from address lists
Hide From Outlook ClientshideFromOutlookClientsBooleanWhether the group is hidden from Outlook clients
Is Subscribed By MailisSubscribedByMailBooleanWhether the signed-in user is subscribed by mail
Is ArchivedisArchivedBooleanWhether the associated team is archived
Unseen CountunseenCountIntegerCount of unseen conversations for the signed-in user
Has Members With License ErrorshasMembersWithLicenseErrorsBooleanWhether the group has members with license errors
Is Management RestrictedisManagementRestrictedBooleanWhether the group is in a restricted management unit
License Processing StatelicenseProcessingStateStringProcessing state of group license assignment
Additional PropertiesadditionalPropertiesList<DynamicObject>Additional properties from user-defined query

Behavior and limits

This implementation maps the returned collection without following or exposing @odata.nextLink. A result can contain only the first page; do not treat it as a complete tenant or resource inventory.

Query inputs are passed through or mapped to OData parameters as implemented. Endpoint-specific query support, advanced directory query requirements, and property visibility still apply.

Retrieves direct memberOf entries cast to microsoft.graph.group. It does not calculate transitive group membership.

Use in Flow

Use MS Entra – Users – Get User Groups where supported. Use a Microsoft 365 application connector configured as Set as default for Flow automations only if the endpoint and target support application access. Supply required values, retain useful outputs, and add fault handling. Delegated connections are not supported for CloudTools Flow automation. The action processes only the first input request.

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.GetEntraUserGroups.GetEntraUserGroupsInput request =
    new Apptigent.GetEntraUserGroups.GetEntraUserGroupsInput();
request.userIdOrPrincipalName = 'alex@contoso.com';
request.filterQuery = 'startswith(displayName,\'Sales\')';
request.selectQuery = 'id,displayName,mail';
request.orderbyQuery = 'displayName asc';
request.topQuery = '25';



List<List<Apptigent.MSEntraGroup>> results =
    Apptigent.GetEntraUserGroups.getUserGroups(
        new List<Apptigent.GetEntraUserGroups.GetEntraUserGroupsInput>{ request }
    );
System.debug(results);

Use in a Lightning Web Component

Use getEntraUserGroups 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
filterQueryrequest.filterQuery
selectQueryrequest.selectQuery
orderbyQueryrequest.orderbyQuery
topQueryrequest.topQuery

entraActionExample.js

import { LightningElement } from 'lwc';
import { getEntraUserGroups } 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 = 'alex@contoso.com';
            request.filterQuery = 'startswith(displayName,\'Sales\')';
            request.selectQuery = 'id,displayName,mail';
            request.orderbyQuery = 'displayName asc';
            request.topQuery = '25';
            this.result = await getEntraUserGroups(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.

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 – Get User Groups

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