Skip to content

Commit 1d4767d

Browse files
authored
Merge pull request MicrosoftDocs#10208 from MicrosoftDocs/CBAUpdate-chrisda
CBAUpdate-chrisda to Main
2 parents 882172c + c349a17 commit 1d4767d

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

exchange/docs-conceptual/app-only-auth-powershell-v2.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ After you register the certificate with your application, you can use the privat
291291

292292
### Step 5: Assign Azure AD roles to the application
293293

294+
You have two options:
295+
296+
- **Assign Azure AD roles to the application**: This method is supported in Exchange Online PowerShell and Security & Compliance PowerShell.
297+
- **Assign custom Exchange Online role groups to the application**: Currently, this method is supported only in Exchange Online PowerShell, and only when you connect in [REST API mode](exchange-online-powershell-v2.md#updates-for-version-300-the-exo-v3-module) (don't use the _UseRPSSession_ switch in the **Connect-ExchangeOnline** command).
298+
299+
> [!NOTE]
300+
> You can also combine both methods to assign permissions. Like using Azure AD roles for the "Exchange Recipient Administrator" role and assign your custom RBAC role to extend the permissions.
301+
302+
#### Assign Azure AD roles to the application
303+
294304
The supported Azure AD roles are described in the following table:
295305

296306
|Role|Exchange Online<br>PowerShell|Security & Compliance<br>PowerShell|
@@ -357,3 +367,60 @@ For general instructions about assigning roles in Azure AD, see [View and assign
357367
- **Security & Compliance PowerShell**:
358368

359369
![The role assignments page after to added the app to the role for Security & Compliance PowerShell.](media/exo-app-only-auth-app-assigned-to-role-scc.png)
370+
371+
#### Assign custom Exchange Online role groups to the application
372+
373+
> [!NOTE]
374+
> Remember, this method is supported only in Exchange Online PowerShell, and only when you connect in [REST API mode](exchange-online-powershell-v2.md#updates-for-version-300-the-exo-v3-module) (don't use the _UseRPSSession_ switch in the **Connect-ExchangeOnline** command).
375+
376+
For information about creating custom role groups, see [Create role groups](/exchange/permissions-exo/role-groups#create-role-groups). The custom role group that you assign to the application can contain any combination of built-in and custom roles.
377+
378+
To assign custom Exchange Online role groups to the application, do the following steps:
379+
380+
1. In [Azure Active Directory PowerShell for Graph](/powershell/azure/active-directory/install-adv2), run the following command to store the details of the Azure application that you registered in [Step 1](#step-1-register-the-application-in-azure-ad) in a variable:
381+
382+
```powershell
383+
$<VariableName1> = Get-AzureADServicePrincipal -SearchString "<AppName>"
384+
```
385+
386+
For example:
387+
388+
```powershell
389+
$AADApp = Get-AzureADServicePrincipal -SearchString "ExO PowerShell CBA"
390+
```
391+
392+
For detailed syntax and parameter information, see [Get-AzureADServicePrincipal](/powershell/module/azuread/get-azureadserviceprincipal).
393+
394+
2. In the same PowerShell window, connect to [Exchange Online PowerShell](connect-to-exchange-online-powershell.md) and run the following commands to:
395+
- Create an Exchange Online service principal object for the Azure application.
396+
- Store the details of the service principal in a variable.
397+
398+
```powershell
399+
New-ServicePrincipal -AppId $<VariableName1>.AppId -ServiceId $<VariableName1>.ObjectId -DisplayName "<Descriptive Name>"
400+
401+
$<VariableName2> = Get-ServicePrincipal -Identity "<Descriptive Name>"
402+
```
403+
404+
For example:
405+
406+
```powershell
407+
New-ServicePrincipal -AppId $AADApp.AppId -ServiceId $AADApp.ObjectId -DisplayName "SP for Azure App ExO PowerShell CBA"
408+
409+
$SP = Get-ServicePrincipal -Identity "SP for Azure App ExO PowerShell CBA"
410+
```
411+
412+
For detailed syntax and parameter information, see [New-ServicePrincipal](/powershell/module/exchange/new-serviceprincipal).
413+
414+
3. In Exchange Online PowerShell, run the following command to add the service principal as a member of the custom role group:
415+
416+
```powershell
417+
Add-RoleGroupMember -Identity "<CustomRoleGroupName>" -Member <$<VariableName2>.Identity | $<VariableName2>.ServiceId | $<VariableName2>.Id>
418+
```
419+
420+
For example:
421+
422+
```powershell
423+
Add-RoleGroupMember -Identity "Contoso View-Only Recipients" -Member $SP.Identity
424+
```
425+
426+
For detailed syntax and parameter information, see [Add-RoleGroupMember](/powershell/module/exchange/add-rolegroupmember).

0 commit comments

Comments
 (0)