Is it possible to create an app-only credential, which has scoped AdministrativeUnit.ReadWrite.All permissions ?

Harish Ganesan 0 Reputation points
2026-11-12T10:36:19.27+00:00

From what i read around, Administrative units allow us to scope certain directory operations to a certain groups of principals within a tenant. I am working on an application, which handles some directory operations for a particular group of users. For this application, I need to create a least-privilege credential which can invite guest users, add these guest users to a specific AU, delete guest users, create groups inside the same AU, add guest users to the created groups. But as far as I can understand from the various documentation sources, it seems like it is not possible to create an application credential ( non-delegated ) which is scoped to a particular AU. Is my understanding of the issue complete ?

If what I said above is right, then what options do I have with me to perform the task I mentioned above ? If not, what would be the least-privilege permissions that I need to assign to the application SP to acheive the above ?

Thanks.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments

2 answers

Sort by: Most helpful
  1. Vasil Michev 128.7K Reputation points MVP Volunteer Moderator
    2026-11-12T11:42:25.2366667+00:00

    There are two ways you can go about granting permissions in Microsoft 365. First one is by granting the corresponding role/scope on the API layer, if your scenario granting AdministrativeUnit.ReadWrite.All app permissions. As you've correctly noted, those are unrestricted, tenant-wide permissions and will not prevent your app from managing other objects.

    The other way is by granting an admin role to the corresponding principal, be it user or app. In this scenario, the permissions on the API side are dictated by what the role allows, and as role assignments can indeed be scoped to an AU, the effective permissions are also scoped. And yes, applications/service principals can also gain access in this way.

    So for your scenario, identify which Entra/Microsoft 365 admin role is the lowest privileged one, and create an AU-scoped assignment for it, with your app as the target. Do NOT grant AdministrativeUnit.ReadWrite.All permissions on the app directly. If you cannot identify a single admin role that contains all required permissions, you can assign multiple (scoped) ones, or use a combination of admin role and application permissions. But remember, the latter cannot be scoped, so the app will always have access to all corresponding objects.

    Was this answer helpful?


  2. AI answer

    2026-11-12T10:40:49.0333333+00:00

    A service principal can receive a Microsoft Entra role scoped to an administrative unit, but AdministrativeUnit.ReadWrite.All and the other Microsoft Graph application permissions required by this workflow cannot themselves be restricted to one AU. ^1^

    Consequently, a fully unattended app can perform the workflow, but Microsoft Entra cannot enforce the target AU as the authorization boundary for every operation. The application must enforce that boundary itself.

    Grant only the application permissions required by the operations you implement:

    Operation Least-privileged application permission AU-scoped?
    Invite a guest User.Invite.All No. Invitation creates the guest in the tenant; it does not place the guest in an AU. B2B invitations must also be enabled. ^2^
    Add an existing guest to the AU AdministrativeUnit.ReadWrite.All No. This application permission can modify AU membership tenant-wide. ^3^
    Create a group directly in the AU Group.Create + AdministrativeUnit.Read.All Requires either Groups Administrator or User Administrator assigned to the service principal at that AU, plus directory-read access. ^3^
    Add the guest to the group GroupMember.ReadWrite.All No; the application permission can modify eligible groups throughout the tenant. ^4^
    Delete the guest account User.ReadWrite.All No; it can delete nonprivileged users outside the AU as well. Extra role privilege is required for users holding privileged administrative roles. ^5^

    For direct group creation under the AU endpoint, choose Groups Administrator unless the app also needs AU-scoped user-administration capabilities. Do not add User Administrator merely for group creation, because either role satisfies that API’s role requirement.

    The service principal also needs directory-read access. Microsoft documents that service principals do not receive directory-read permissions by default and that these read permissions cannot currently be scoped to an AU. Assign tenant-scoped Directory Readers, or grant an appropriate Graph read application permission such as Directory.Read.All. ^6^

    Assign the AU-scoped role

    Prerequisites:

    • Microsoft Entra PowerShell installed.
    • A Privileged Role Administrator executing the assignment.
    • Microsoft Entra ID P1 or P2 for the administrative-unit administrator assignment; AU members require Microsoft Entra ID Free. ^7^
    Connect-Entra -Scopes 'Application.Read.All',
        'AdministrativeUnit.Read.All',
        'RoleManagement.ReadWrite.Directory'
    
    $sp = Get-EntraServicePrincipal -Filter "DisplayName eq 'My Application'"
    $au = Get-EntraAdministrativeUnit -Filter "DisplayName eq 'My Admin Unit'"
    $role = Get-EntraDirectoryRoleDefinition `
        -Filter "DisplayName eq 'Groups Administrator'"
    
    New-EntraDirectoryRoleAssignment `
        -PrincipalId $sp.Id `
        -RoleDefinitionId $role.Id `
        -DirectoryScopeId "/administrativeUnits/$($au.Id)"
    

    Microsoft Entra supports assigning AU-scoped roles to service principals. ^1^

    This script assigns the Entra role only. It does not add Microsoft Graph application permissions or grant admin consent; configure those separately on Entra ID → App registrations → your app → API permissions.

    End-to-end API sequence

    1. POST /invitations using User.Invite.All; retain the returned guest user ID.
    2. POST /directory/administrativeUnits/{au-id}/members/$ref to add that guest ID to the AU.
    3. POST /directory/administrativeUnits/{au-id}/members to create the group directly within the AU.
    4. POST /groups/{group-id}/members/$ref to add the guest to the group.
    5. When offboarding, remove group/AU memberships as needed, then optionally call DELETE /users/{guest-id}.

    Adding a group to an AU scopes management of the group object, not the users in that group. Users must be added directly to the AU when their user objects need AU-scoped administration. ^7^

    Deletion warning: DELETE /users/{guest-id} is destructive and can affect access, ownership, licenses, and downstream resources. Before automation, verify the tenant and immutable guest object ID, check ownership/dependencies, log the operation, and preferably require approval.

    Security boundary

    The app should maintain an allowlist containing the permitted AU ID and group IDs, reject arbitrary object IDs, and verify AU membership before updates or deletion. However, these checks are defense in depth—not a Microsoft Entra authorization boundary. A compromised credential carrying AdministrativeUnit.ReadWrite.All, GroupMember.ReadWrite.All, or User.ReadWrite.All remains technically capable of operations elsewhere in the tenant.

    A delegated design can enforce AU-scoped Entra roles for operations that honor those roles, but it does not make guest invitation AU-scoped and does not automatically constrain operations independently authorized by tenant-wide Graph permissions.


    References

    1. Manage roles
    2. Create invitation
    3. Add a member
    4. Add members
    5. Delete a user
    6. Assign Microsoft Entra roles
    7. Administrative units in Microsoft Entra ID
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.