Applies to: Microsoft Graph and Exchange Web Services (EWS) application connections
When using application permissions in either Microsoft Graph or EWS, the default behavior grants the application access to all mailboxes in the tenant. To comply with the principle of least privilege and minimize security exposure, Microsoft now recommends using Role-Based Access Control (RBAC) for Applications to limit this access.
⚠️ Important: Microsoft is deprecating support for Application Access Policies. RBAC for Applications is the preferred and future-proof method for controlling mailbox access via application permissions.
Learn more in Microsoft’s announcement.
Prerequisites
To proceed, ensure you have the following:
-
A mail-enabled security group in Microsoft 365. Only users in this group will be accessible by the application.
-
Exchange Online PowerShell access with appropriate permissions.
-
The Application (client) ID and Object ID for the Riva Enterprise Application, found in Azure Active Directory > Enterprise Applications.
Step-by-Step: Restricting Mailbox Access with RBAC
1. Connect to Exchange Online via PowerShell
If you haven’t connected yet, follow Microsoft’s guide:
👉 Connect to Exchange Online PowerShell
2. Identify the Mail-Enabled Security Group
You’ll need the Distinguished Name (DN) of the security group Riva users belong to.
Get-Group "YourGroupName" | Select-Object -Property DistinguishedName
📝 Only mail-enabled security groups are supported. Microsoft 365 groups, distribution groups, and security-only groups may not work properly with this method.
3. Create a Management Scope
Create a custom scope that limits access to the selected group:
New-ManagementScope -Name "RivaSyncScope" -RecipientRestrictionFilter {memberofGroup -eq "CN=GroupName,OU=domain.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=...,DC=COM"}
-
Replace the value in
memberofGroup
with the DN obtained in Step 2. -
The scope limits the application to only mailboxes in this group.
4. Create a Service Principal for the Application
New-ServicePrincipal -AppId <ApplicationId> -ObjectId <ObjectId> -DisplayName "RBAC RivaSync"
Replace <ApplicationId>
and <ObjectId>
with values from your Riva Azure Enterprise Application.