RBAC for Applications in Exchange Online: How to Limit an App to Named Mailboxes
How to configure RBAC for Applications in Exchange Online so an app can read only the mailboxes you name: the five commands, how to test the limit, the Entra permission that silently undoes it, and how long Exchange takes to apply it.

Short answer: RBAC for Applications lets you give an app access to mail in the mailboxes you name and no others. You register the app's service principal in Exchange Online, create a management scope that matches those mailboxes, and assign an application role inside that scope. Then you test it with Test-ServicePrincipalAuthorization. Two things catch people out. A mail permission granted in Microsoft Entra ID overrides the scope. And Exchange can take from 30 minutes to 2 hours to apply the change.
This guide is for Microsoft 365 administrators and IT providers who are asked to approve an app that reads or writes mail without a signed-in user: a ticketing tool, a scanner, a backup, a reporting service. It covers Exchange Online only.
Why you need it
An app that works without a signed-in user is usually given an application permission in Microsoft Entra ID, such as Mail.Read. That permission is not limited to a mailbox. It covers every mailbox in the organization.
Most apps need far less. A tool that reports on orders@contoso.com has no reason to be able to read the finance director's mail.
RBAC for Applications closes that gap. The permission is granted inside Exchange Online, together with a scope that says which mailboxes it applies to. Microsoft describes it as the replacement for Application Access Policies, the older way to do the same job.
What you need before you start
| You need | Detail |
|---|---|
| The right role | Membership of the Organization Management role group in Exchange Online. In Microsoft Entra ID, the Exchange Administrator role |
| PowerShell | The ExchangeOnlineManagement module, and Connect-ExchangeOnline |
| The app in your organization | The app must already appear under Enterprise applications in the Entra admin center. For another company's app, that happens when an administrator approves it |
| Two ids | The Application ID and the Object ID from the app's Enterprise applications page |
| The mailboxes | The primary address of each mailbox the app may reach |
Take both ids from Enterprise applications, not from App registrations. The two pages show different object ids for the same app, and the wrong one fails.
The five steps
The example gives an app read-only access to one shared mailbox, orders@contoso.com.
1. Connect
Connect-ExchangeOnline
2. Register the app's service principal in Exchange
New-ServicePrincipal -AppId <Application ID> -ObjectId <Object ID> -DisplayName "Orders reporting app"
This creates a pointer in Exchange to the service principal that already exists in Entra. It grants nothing.
3. Create a management scope that matches only your mailboxes
New-ManagementScope -Name "Orders-Reporting-Scope" -RecipientRestrictionFilter "PrimarySmtpAddress -eq 'orders@contoso.com'"
For several mailboxes, join the conditions with -or:
New-ManagementScope -Name "Orders-Reporting-Scope" -RecipientRestrictionFilter "PrimarySmtpAddress -eq 'orders@contoso.com' -or PrimarySmtpAddress -eq 'support@contoso.com'"
A scope is a filter on mailbox properties, so you can also scope by a custom attribute or by membership of a group. An exact address is the easiest filter to read back later and the hardest to widen by accident.
4. Assign the role inside the scope
New-ManagementRoleAssignment -App <Application ID> -Role "Application Mail.Read" -CustomResourceScope "Orders-Reporting-Scope"
5. Test what the app can reach
Test-ServicePrincipalAuthorization -Identity <Application ID> -Resource orders@contoso.com | Format-Table RoleName, GrantedPermissions, AllowedResourceScope, ScopeType, InScope
InScope should read True for a mailbox you named. Run it again with a mailbox you did not name, and it should read False. If you leave out -Resource, the column reads Not Run.
Run the test for one mailbox inside the scope and one outside it. A limit you have only tested from the inside has not been tested.
Which role to assign
Assign the smallest role that does the job. These are the mail roles most apps ask for:
| Role | What the app can do |
|---|---|
Application Mail.ReadBasic | Read mail, but not the body, the preview or attachments |
Application Mail.Read | Read mail |
Application Mail.ReadWrite | Create, read, change and delete mail. It cannot send |
Application Mail.Send | Send mail as any mailbox in the scope |
Application MailboxSettings.Read | Read mailbox settings, such as time zone and working hours |
Microsoft's page lists the full set, including calendar and contact roles. An app that only reports on mail needs a read role. Be slow to grant Mail.Send.
The mistake that undoes the scope
Permissions from RBAC for Applications are added to whatever the app holds in Microsoft Entra ID. They do not restrict it.
So if the app has Mail.Read in Entra and you also give it a scoped Application Mail.Read in Exchange, the app can still read every mailbox. The Entra grant wins, because it has no scope.
Check the app's API permissions in Entra. For the scope to mean anything, the app should hold no mail permission there. Test-ServicePrincipalAuthorization will not warn you: it reports only what Exchange granted and leaves out anything granted in Entra.
This is the first question to ask a vendor: does your app request Mail.Read at sign-up, or does it rely on Exchange scoping alone? If its consent screen asks to read mail in all mailboxes, the scope you create afterwards is decoration.
What we saw when we ran it
We build a shared mailbox audit that is given access in exactly this way, so we ran these commands against a real tenant on 27 November 2026.
- The app held no API permission in Entra. The token it received carried no roles at all.
- With only the Exchange assignment, it read the one shared mailbox in its scope through Microsoft Graph.
- It was refused, with HTTP 403, on a second shared mailbox and on a user's own mailbox.
That confirms the point above from the other side. Exchange scoping does not need an Entra mail permission underneath it. It works alone, and it is safer alone.
How long it takes
Do not expect the app to work the minute the script finishes. Exchange caches each app's permissions. Microsoft documents the cache as lasting between 30 minutes and 2 hours, depending on how recently the app has been calling.
In our run, the app was still refused more than an hour after the test command showed the mailbox in scope. The cause was our own checking. We explain what happened, and the three rules that follow, in Still refused after the script ran? Exchange's permission cache.
The test command bypasses the cache. Use it to confirm your work. Use patience for the rest.
Adding a mailbox later
Change the scope's filter. The role assignment stays as it is.
Set-ManagementScope -Identity "Orders-Reporting-Scope" -RecipientRestrictionFilter "PrimarySmtpAddress -eq 'orders@contoso.com' -or PrimarySmtpAddress -eq 'billing@contoso.com'"
Then run the test again for the new mailbox.
Removing the access
Remove the assignment, then the scope:
Get-ManagementRoleAssignment -RoleAssignee <Application ID> | Where-Object CustomResourceScope -eq "Orders-Reporting-Scope" | Remove-ManagementRoleAssignment -Confirm:$false
Remove-ManagementScope -Identity "Orders-Reporting-Scope" -Confirm:$false
To remove the app from the organization altogether, delete it under Enterprise applications in Entra. Exchange then removes its service principal and its assignments by itself. The management scope is left behind, so remove that too.
Removal is a permission change like any other, so allow for the same cache before you treat the access as gone.
A checklist for approving someone else's app
- Ask which application role the app needs, and why.
- Ask whether it requests any mail permission in Entra. The answer you want is no.
- Name the mailboxes yourself. Do not accept "all shared mailboxes" as a scope.
- Read the script before you run it.
- Test one mailbox inside the scope and one outside.
- Write down the scope's name, so you can find and remove it later.
Frequently asked questions
Does the app still need a permission in Microsoft Entra ID?
Not for mail. In our run the app had no API permission in Entra and read the scoped mailbox with the Exchange role alone. A mail permission in Entra would have widened its access to every mailbox.
Is this the same as an Application Access Policy?
No. Application Access Policies restrict a permission that was granted in Entra. RBAC for Applications grants the permission in Exchange, already scoped. Microsoft says RBAC for Applications replaces Application Access Policies, and its page describes how to move from one to the other.
Does it work for shared mailboxes?
Yes. A shared mailbox is matched by a scope filter like any other mailbox. The mailbox in our run was a shared mailbox.
Which protocols does it cover?
Microsoft Graph and Exchange Web Services. Microsoft notes that Autodiscover cannot be reached with these roles.
Can I scope by group instead of by address?
Yes, with a filter on group membership. Microsoft's page gives the syntax. Only direct members count: members of a nested group are out of scope.
How do I see everything an app can reach?
Run Test-ServicePrincipalAuthorization -Identity <Application ID> without a mailbox. It lists each role and the scope it is limited to. Then check the app's API permissions in Entra, because the test does not show those.
Sources
- Microsoft Learn, Role Based Access Control for Applications in Exchange Online, read 30 November 2026.
- Our own run of these commands in one Microsoft 365 tenant, 27 November 2026.