Skip to content

Commit 5a4e32c

Browse files
authored
Merge pull request #217157 from omondiatieno/grant-admin-consent
add zone pivots with Microsoft Graph content
2 parents 5fcf533 + 9c73238 commit 5a4e32c

File tree

2 files changed

+155
-12
lines changed

2 files changed

+155
-12
lines changed

articles/active-directory/manage-apps/grant-admin-consent.md

Lines changed: 146 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
---
22
title: Grant tenant-wide admin consent to an application
3-
description: Learn how to grant tenant-wide consent to an application so that end-users are not prompted for consent when signing in to an application.
3+
description: Learn how to grant tenant-wide consent to an application so that end-users aren't prompted for consent when signing in to an application.
44
services: active-directory
55
author: eringreenlee
66
manager: CelesteDG
77
ms.service: active-directory
88
ms.subservice: app-mgmt
99
ms.workload: identity
1010
ms.topic: how-to
11-
ms.date: 09/02/2022
11+
ms.date: 11/07/2022
1212
ms.author: ergreenl
1313
ms.collection: M365-identity-device-management
1414
ms.custom: contperf-fy22q2
15+
zone_pivot_groups: enterprise-apps-minus-aad-powershell
1516

1617
#customer intent: As an admin, I want to grant tenant-wide admin consent to an application in Azure AD.
1718
---
@@ -20,13 +21,11 @@ ms.custom: contperf-fy22q2
2021

2122
In this article, you'll learn how to grant tenant-wide admin consent to an application in Azure Active Directory (Azure AD). To understand how individual users consent, see [Configure how end-users consent to applications](configure-user-consent.md).
2223

23-
When you grant tenant-wide admin consent to an application, you give the application access on behalf of the whole organization to the permissions requested. Granting admin consent on behalf of an organization is a sensitive operation, potentially allowing the application's publisher access to significant portions of your organization's data, or the permission to do highly privileged operations. Examples of such operations might be role management, full access to all mailboxes or all sites, and full user impersonation.
24+
When you grant tenant-wide admin consent to an application, you give the application access on behalf of the whole organization to the permissions requested. Granting admin consent on behalf of an organization is a sensitive operation, potentially allowing the application's publisher access to significant portions of your organization's data, or the permission to do highly privileged operations. Examples of such operations might be role management, full access to all mailboxes or all sites, and full user impersonation. Carefully review the permissions that the application is requesting before you grant consent.
2425

2526
By default, granting tenant-wide admin consent to an application will allow all users to access the application unless otherwise restricted. To restrict which users can sign-in to an application, configure the app to [require user assignment](application-properties.md#assignment-required) and then [assign users or groups to the application](assign-user-or-group-access-portal.md).
2627

27-
Tenant-wide admin consent to an app grants the app and the app's publisher access to your organization's data. Carefully review the permissions that the application is requesting before you grant consent. For more information on consenting to applications, see [Azure Active Directory consent framework](../develop/consent-framework.md).
28-
29-
Granting tenant-wide admin consent may revoke any permissions which had previously been granted tenant-wide for that application. Permissions which have previously been granted by users on their own behalf will not be affected.
28+
Granting tenant-wide admin consent may revoke any permissions that had previously been granted tenant-wide for that application. Permissions that have previously been granted by users on their own behalf won't be affected.
3029

3130
## Prerequisites
3231

@@ -43,6 +42,8 @@ To grant tenant-wide admin consent, you need:
4342

4443
You can grant tenant-wide admin consent through *Enterprise applications* if the application has already been provisioned in your tenant. For example, an app could be provisioned in your tenant if at least one user has already consented to the application. For more information, see [How and why applications are added to Azure Active Directory](../develop/active-directory-how-applications-are-added.md).
4544

45+
:::zone pivot="portal"
46+
4647
To grant tenant-wide admin consent to an app listed in **Enterprise applications**:
4748

4849
1. Sign in to the [Azure portal](https://portal.azure.com) with one of the roles listed in the prerequisites section.
@@ -81,6 +82,145 @@ where:
8182

8283
As always, carefully review the permissions an application requests before granting consent.
8384

85+
86+
:::zone-end
87+
88+
89+
:::zone pivot="ms-powershell"
90+
91+
In the following example, you'll grant delegated permissions defined by a resource enterprise application to a client enterprise application on behalf of all users.
92+
93+
In the example, the resource enterprise application is Microsoft Graph of object ID `7ea9e944-71ce-443d-811c-71e8047b557a`. The Microsoft Graph defines the delegated permissions, `User.Read.All` and `Group.Read.All`. The consentType is `AllPrincipals`, indicating that you're consenting on behalf of all users in the tenant. The object ID of the client enterprise application is `b0d9b9e3-0ecf-4bfd-8dab-9273dd055a941`.
94+
95+
> [!CAUTION]
96+
> Be careful! Permissions granted programmatically are not subject to review or confirmation. They take effect immediately.
97+
98+
## Grant admin consent for delegated permissions
99+
100+
1. Connect to Microsoft Graph PowerShell:
101+
102+
```powershell
103+
Connect-MgGraph -Scopes "Application.ReadWrite.All", "DelegatedPermissionGrant.ReadWrite.All"
104+
```
105+
106+
1. Retrieve all the delegated permissions defined by Microsoft graph (the resource application) in your tenant application. Identify the delegated permissions that you'll grant the client application. In this example, the delegation permissions are `User.Read.All` and `Group.Read.All`
107+
108+
```powershell
109+
Get-MgServicePrincipal -Filter "displayName eq 'Microsoft Graph'" -Property Oauth2PermissionScopes | Select -ExpandProperty Oauth2PermissionScopes | fl
110+
```
111+
112+
1. Grant the delegated permissions to the client enterprise application by running the following request.
113+
114+
```powershell
115+
$params = @{
116+
117+
"ClientId" = "b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94"
118+
"ConsentType" = "AllPrincipals"
119+
"ResourceId" = "7ea9e944-71ce-443d-811c-71e8047b557a"
120+
"Scope" = "User.Read.All Group.Read.All"
121+
}
122+
123+
New-MgOauth2PermissionGrant -BodyParameter $params |
124+
Format-List Id, ClientId, ConsentType, ResourceId, Scope
125+
```
126+
127+
1. Confirm that you've granted tenant wide admin consent by running the following request.
128+
129+
```powershell
130+
Get-MgOauth2PermissionGrant-Filter "clientId eq 'b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94' consentType eq 'AllPrincipals'"
131+
```
132+
## Grant admin consent for application permissions
133+
134+
In the following example, you grant the Microsoft Graph enterprise application (the principal of ID `b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94`) an app role (application permission) of ID `df021288-bdef-4463-88db-98f22de89214` that's exposed by a resource enterprise application of ID `7ea9e944-71ce-443d-811c-71e8047b557a`.
135+
136+
1. Connect to Microsoft Graph PowerShell:
137+
138+
```powershell
139+
Connect-MgGraph -Scopes "Application.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"
140+
```
141+
142+
1. Retrieve the app roles defined by Microsoft graph in your tenant. Identify the app role that you'll grant the client enterprise application. In this example, the app role ID is `df021288-bdef-4463-88db-98f22de89214`.
143+
144+
```powershell
145+
Get-MgServicePrincipal -Filter "displayName eq 'Microsoft Graph'" -Property AppRoles | Select -ExpandProperty appRoles |fl
146+
```
147+
148+
1. Grant the application permission (app role) to the client enterprise application by running the following request.
149+
150+
```powershell
151+
$params = @{
152+
"PrincipalId" ="b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94"
153+
"ResourceId" = "2cab1707-656d-40cc-8522-3178a184e03d"
154+
"AppRoleId" = "df021288-bdef-4463-88db-98f22de89214"
155+
}
156+
157+
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId '2cab1707-656d-40cc-8522-3178a184e03d' -BodyParameter $params |
158+
Format-List Id, AppRoleId, CreatedDateTime, PrincipalDisplayName, PrincipalId, PrincipalType, ResourceDisplayName
159+
```
160+
161+
:::zone-end
162+
163+
:::zone pivot="ms-graph"
164+
165+
Use [Graph Explorer](https://developer.microsoft.com/graph/graph-explorer) to grant both delegated and application permissions.
166+
167+
## Grant admin consent for delegated permissions
168+
169+
In the following example, you'll grant delegated permissions defined by a resource enterprise application to a client enterprise application on behalf of all users.
170+
171+
In the example, the resource enterprise application is Microsoft Graph of object ID `7ea9e944-71ce-443d-811c-71e8047b557a`. The Microsoft Graph defines the delegated permissions, `User.Read.All` and `Group.Read.All`. The consentType is `AllPrincipals`, indicating that you're consenting on behalf of all users in the tenant. The object ID of the client enterprise application is `b0d9b9e3-0ecf-4bfd-8dab-9273dd055a941`.
172+
173+
> [!CAUTION]
174+
> Be careful! Permissions granted programmatically are not subject to review or confirmation. They take effect immediately.
175+
176+
1. Retrieve all the delegated permissions defined by Microsoft graph (the resource application) in your tenant application. Identify the delegated permissions that you'll grant the client application. In this example, the delegation permissions are `User.Read.All` and `Group.Read.All`
177+
178+
```http
179+
GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq 'Microsoft Graph'&$select=id,displayName,appId,oauth2PermissionScopes
180+
```
181+
182+
1. Grant the delegated permissions to the client enterprise application by running the following request.
183+
184+
```http
185+
POST https://graph.microsoft.com/v1.0/oauth2PermissionGrants
186+
187+
Request body
188+
{
189+
"clientId": "b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94",
190+
"consentType": "AllPrincipals",
191+
"resourceId": "7ea9e944-71ce-443d-811c-71e8047b557a",
192+
"scope": "User.Read.All Group.Read.All"
193+
}
194+
```
195+
1. Confirm that you've granted tenant wide admin consent by running the following request.
196+
197+
```http
198+
GET https://graph.microsoft.com/v1.0/oauth2PermissionGrants?$filter=clientId eq 'b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94' and consentType eq 'AllPrincipals'
199+
```
200+
## Grant admin consent for application permissions
201+
202+
In the following example, you grant the Microsoft Graph enterprise application (the principal of ID `b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94`) an app role (application permission) of ID `df021288-bdef-4463-88db-98f22de89214` that's exposed by a resource enterprise application of ID `7ea9e944-71ce-443d-811c-71e8047b557a`.
203+
204+
1. Retrieve the app roles defined by Microsoft graph in your tenant. Identify the app role that you'll grant the client enterprise application. In this example, the app role ID is `df021288-bdef-4463-88db-98f22de89214`
205+
206+
```http
207+
GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq 'Microsoft Graph'&$select=id,displayName,appId,appRoles
208+
```
209+
1. Grant the application permission (app role) to the client enterprise application by running the following request.
210+
211+
```http
212+
POST https://graph.microsoft.com/v1.0/servicePrincipals/7ea9e944-71ce-443d-811c-71e8047b557a/appRoleAssignedTo
213+
214+
Request body
215+
216+
{
217+
"principalId": "b0d9b9e3-0ecf-4bfd-8dab-9273dd055a94",
218+
"resourceId": "7ea9e944-71ce-443d-811c-71e8047b557a",
219+
"appRoleId": "df021288-bdef-4463-88db-98f22de89214"
220+
}
221+
```
222+
:::zone-end
223+
84224
## Next steps
85225

86226
[Configure how end-users consent to applications](configure-user-consent.md)

articles/active-directory/manage-apps/manage-application-permissions.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: active-directory
88
ms.subservice: app-mgmt
99
ms.workload: identity
1010
ms.topic: how-to
11-
ms.date: 10/23/2021
11+
ms.date: 11/07/2022
1212
ms.author: jawoods
1313
ms.reviewer: phsignor
1414
zone_pivot_groups: enterprise-apps-minus-graph
@@ -18,11 +18,11 @@ ms.collection: M365-identity-device-management
1818

1919
---
2020

21-
# Review permissions granted to applications
21+
# Review permissions granted to enterprise applications
2222

2323
In this article, you'll learn how to review permissions granted to applications in your Azure Active Directory (Azure AD) tenant. You may need to review permissions when you've detected a malicious application or the application has been granted more permissions than is necessary.
2424

25-
The steps in this article apply to all applications that were added to your Azure Active Directory (Azure AD) tenant via user or admin consent. For more information on consenting to applications, see [Azure Active Directory consent framework](../develop/consent-framework.md).
25+
The steps in this article apply to all applications that were added to your Azure Active Directory (Azure AD) tenant via user or admin consent. For more information on consenting to applications, see [User and admin consent](user-admin-consent-overview.md).
2626

2727
## Prerequisites
2828

@@ -32,7 +32,7 @@ To review permissions granted to applications, you need:
3232
- One of the following roles: Global Administrator, Cloud Application Administrator, Application Administrator.
3333
- A Service principal owner who isn't an administrator is able to invalidate refresh tokens.
3434

35-
## Review application permissions
35+
## Review permissions
3636

3737
:::zone pivot="portal"
3838

@@ -53,6 +53,9 @@ Each option generates PowerShell scripts that enable you to control user access
5353

5454
:::zone pivot="aad-powershell"
5555

56+
## Revoke permissions
57+
58+
5659
Using the following Azure AD PowerShell script revokes all permissions granted to an application.
5760

5861
```powershell
@@ -72,7 +75,7 @@ $spOAuth2PermissionsGrants | ForEach-Object {
7275
# Get all application permissions for the service principal
7376
$spApplicationPermissions = Get-AzureADServiceAppRoleAssignedTo -ObjectId $sp.ObjectId -All $true | Where-Object { $_.PrincipalType -eq "ServicePrincipal" }
7477
75-
# Remove all delegated permissions
78+
# Remove all application permissions
7679
$spApplicationPermissions | ForEach-Object {
7780
Remove-AzureADServiceAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.objectId
7881
}
@@ -107,7 +110,7 @@ $sp = Get-MgServicePrincipal -ServicePrincipalID "$ServicePrincipalID"
107110
108111
Example: Get-MgServicePrincipal -ServicePrincipalId '22c1770d-30df-49e7-a763-f39d2ef9b369'
109112
110-
# Get all application permissions for the service principal
113+
# Get all delegated permissions for the service principal
111114
$spOAuth2PermissionsGrants= Get-MgOauth2PermissionGrant -All| Where-Object { $_.clientId -eq $sp.Id }
112115
113116
# Remove all delegated permissions

0 commit comments

Comments
 (0)