Forum Discussion

PoorMens_Bravo's avatar
PoorMens_Bravo
Brass Contributor
Aug 05, 2025

Scoping application Crestron to access only room mailboxes of resourcetype Workspace

We got a requirement for to enable application Crestron to be able to access Workspace resourcetype Room mailboxes only. So, we thought of directly tieing the application to these mailboxes over the usual way of assigning it to a group because we had to create a group just for to maintain this delegation.

Below are the steps we performed:

#Create management scope
Connect-ExchangeOnline

New-ManagementScope -Name "Workspace Mailboxes" `
    -RecipientRestrictionFilter "((RecipientTypeDetails -eq 'RoomMailbox') -and (ResourceType -eq 'Workspace'))"
#Assign the management scope to Roles
New-ManagementRoleAssignment `
    -App "<AppID>" `
    -Role "Application Calendars.ReadWrite" `
    -CustomResourceScope "Workspace Mailboxes" `
    -Name "MyApp-WorkspaceOnly"

New-ManagementRoleAssignment `
    -App "<AppID>" `
    -Role "Application MailboxSettings.Read" `
    -CustomResourceScope "Workspace Mailboxes" `
    -Name "MyApp-WorkspaceOnly-Settings"
#Verified the assignment via:
Get-ManagementRoleAssignment -App "<AppID>" | ft Name, Role, CustomResourceScope
Name                      Role                           CustomResourceScope
----                      ----                           -------------------
MyApp-WorkspaceOnly       Application Calendars.ReadWrite Workspace Mailboxes
MyApp-WorkspaceOnly-Settings Application MailboxSettings.Read Workspace Mailboxes

 

Tested the scope of the assignment with a non-workspace mailbox and a workspace mailbox, the scope resulted false for non-workspace mailbox and true for a workspace mailbox.

 

Later, admin consented for API permissions Calendars.ReadWrite, Mailboxsettings.Read & User.Read.All and generated an application secret with validity of 180 days to the application team and shared the secret key.

 

ISSUE: When application team tested the access from Crestron application for a workspace mailbox it is resulting in Authentication Failed. This is the actual issue.

 

In order to test whether this is happening because of scope , performed the below steps:

$TenantId = "<TenantID>"
$AppId = "<AppID>"
$ClientSecret = "<ClientSecret>"

$Body = @{
    grant_type    = "client_credentials"
    client_id     = $AppId
    client_secret = $ClientSecret
    scope         = "https://graph.microsoft.com/.default"
}

$TokenRequest = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token" `
    -Method POST -Body $Body

$AccessToken = $TokenRequest.access_token

$WorkspaceMailbox = "<email address removed for privacy reasons>"
Invoke-RestMethod `
    -Uri "https://graph.microsoft.com/v1.0/users/$WorkspaceMailbox/events" `
    -Headers @{Authorization = "Bearer $AccessToken"}

The expected results for this test was to receive 

Workspace mailbox → Returns events.

Non-Workspace mailbox → Should return 403 Forbidden.

However, it resulted events in both the cases, when dug further I realised that Graph API will override the management scopes created at Exchange level, so need guidance on how we can take this further.

6 Replies

  • The issue got resolved, I believe somewhere in the code of the application, it was not using secret and instead secret code was being used, upon updating that the issue got resolved..... Just stumbled upon this discussion and realized I haven't updated it....

  • Actually thanks VasilMichev​ for pointing that out and I agree that's correct, I just removed the Entra permissions for the application and my Graph test started showing up correctly.... Which means that the scope for the application is working as expected... However, we still stand with the issue of Authentication, I am not sure from where to start investigating that....Is there a place I can check for logs?

  • Did you remove the corresponding permissions (Calendars.ReadWrite, Mailboxsettings.Read) on Graph side? Here's the relevant quote from the documentation: https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac#why-does-my-application-still-have-access-to-mailboxes-that-arent-granted-using-rbac 

    Why does my application still have access to mailboxes that aren't granted using RBAC?

    You need to ensure that you've removed the tenant-wide unscoped permissions you assigned in Microsoft Entra ID. The permissions assigned using RBAC act in addition to grants you make in Microsoft Entra ID. Microsoft Entra permissions can only be constrained using Application Access Policies.

    • PoorMens_Bravo's avatar
      PoorMens_Bravo
      Brass Contributor

      So, I did not migrate from Application access policy, this was a new request and hence went ahead with Application RBAC

      • VasilMichev's avatar
        VasilMichev
        MVP

        That's not what the above means. Just remove the permissions on Entra side and you should be fine.

Resources