asp.net-coreazure-active-directorymicrosoft-graph-apimicrosoft-identity-platform

Does "DelegatedPermissionGrant.ReadWrite.All" allow granting admin consent?


In MS Graph, some delegated permissions need "Admin Consent" and some just need user consent.

For example, the delegated permission User.Read.All requires admin consent. But the delegated permission User.ReadBasic.All does not need admin consent. (But it would still need user consent.)

Screenshot of permissions discussed above

I know that DelegatedPermissionGrant.ReadWrite.All allows the application to grant consent on behalf of the user. But I don't know if it can grant "Admin Consent".

Can an application with DelegatedPermissionGrant.ReadWrite.All grant "Admin Consent"?


Solution

  • Yes, DelegatedPermissionGrant.ReadWrite.All allows a principal to grant admin consent for Delegated permissions only

    AppRoleAssignment.ReadWrite.All allows a principal to grant admin consent for Application permissions

    There are examples on how to do so with the MS Graph API and MS Graph PowerShell here

    https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/grant-admin-consent?pivots=ms-powershell

    MS Graph PowerShell Example

    # The object ID of your Enterprise Application
    $servicePrincipalObjectId = ""
    
    # This is the object ID of the Enterprise Application for Microsoft Graph
    $graphId = Get-MgServicePrincipal -Filter "displayName eq 'Microsoft Graph'" | Select-Object -ExpandProperty Id
    
    # Permissions to grant consent to, space separated
    $scopes = "User.Read.All Directory.Read.All"
    
    $params = @{
        ClientId    = $servicePrincipalObjectId
        ConsentType = "AllPrincipals"
        ResourceId  = $graphId
        Scope       = $scopes
    }
    
    New-MgOauth2PermissionGrant -BodyParameter $params
    

    Before

    enter image description here

    After

    enter image description here