MS Graph API to update Application permissions scope in Enterprise App - azure-ad-graph-api

I have an AzureAD enterprise app that is consented from a multi-tenant app. The permissions have both Application and Delegated as shown in screenshot. See "Type" column.
The home tenant has since updated permissions and rather than disconnecting and reconnecting I want to modify the existing permissions.
Microsoft provides an API to list and patch the oauth2PermissionGrant.
List - https://learn.microsoft.com/en-us/graph/api/oauth2permissiongrant-list?view=graph-rest-1.0&tabs=http#code-try-1
Update - https://learn.microsoft.com/en-us/graph/api/oauth2permissiongrant-update?view=graph-rest-1.0&tabs=http
However, this only lets me list and update the "Delegated" permissions. So querying the permissions only returns the first 4, User.Read. User.ReadBasic.All, User.ReadAll, Group.ReadAll.
Is there a way that I can modify the "Application" permissions as a Global Admin?

Related

Is there a way to temporarily ignore permissions on SharePoint Online for the purposes of a powershell script?

I have a tenant admin account for a SharePoint online tenant. I am tasked with looking at all the sites on the tenant and all the SharePoint groups on each site. Getting a list of sites is easy using PNP libraries (Get-PnPTenantSite). My next step is to loop through each site and get all the security groups associated with each site - also easy using Get-PnPGroup commandlet.
The problem I'm running into is that my tenant admin is not added to some sites - not Site Admin, Not Site Owner, not even Site Reader - and so when my script executes against one of these sites, I'm getting a 403 Forbidden when asking for the groups on the site. Yes, I could avoid this by just adding my tenant admin as an owner on every single site in the tenant, and could probably even do this using a fairly simple powershell script.
However, my question is, why is this necessary? Shouldn't I be able to just run a script with some kind of "tenant admin super-read-permissions" or something that will just temporarily give me all access to everything without having to go through the middle step of adding myself everywhere?
Depending on the needs of your business with SharePoint, it may seem like an unnecessary or extra layer of security. After all, why not allow an administrator to access all the things?
The answer lies in the fact that SharePoint security is designed to allow separation of roles. These roles may not necessarily match exactly how responsibilities are defined in your company.
From Microsoft:
Global Administrators and SharePoint Administrators don't have
automatic access to all sites and each user's OneDrive, but they can
give themselves access to any site or OneDrive.
See https://learn.microsoft.com/en-us/sharepoint/sharepoint-admin-role
Tenant admins have several responsibilities:
Create sites
Delete sites
Manage sharing settings at the organization level
Add and remove site admins
Manage site storage limits
To perform these responsibilities, very little access to the actual sites and their content is required.
Management of access to a site collection and its content is the responsibility of the site collection administrator and site owners.
It sounds like in your company, you wear both hats. You might be creating and deleting sites, and also getting involved in access control or auditing at the site collection level. In these cases, you must use the privilege of the tenant admin (e.g., add and remove site admins) to grant yourself the site collection privileges required to access the information you need.
I recommend not granting yourself these privileges forever. It is helpful to consider that having constant administrative access to all sites is undesirable for a few reasons. For instance:
Search is supposed to be filtered to content that is relevant to the user. If the user is an admin with access to all content, search will not be filtered in a useful way.
While an administrator may certainly grant themselves access to a site, some collaborators would prefer that their content remain private to their team until or unless they require technical support.
All of this addresses the "why" part of your question. As for the technical question, there is currently no "tenant admin super-read-permissions" role that you can use for the data you want to collect.

Application access Policy

If we scope the Application access Policy to specific mail enabled group and grant access only to the member of the group there are chances for any userid can be added to the group and leverage full access to the mailbox. What level of security controls can be added to prevent this??
Use the New-ApplicationAccessPolicy cmdlet to restrict or deny access to a specific set of mailboxes by an application that uses APIs (Outlook REST, Microsoft Graph, or Exchange Web Services (EWS)). These policies are complementary to the permission scopes that are declared by the application.
While scope-based resource access like Mail.Read or Calendar.Read is effective to ensure that the application can only read email or events within a mailbox and not do anything else, application access policies allow admins to enforce limits that are based on a list of mailboxes. For example, apps developed for one country shouldn't have access to data from other countries. Or, or a CRM integration application should only access calendars in the Sales organization and no other departments.
Reference: New-ApplicationAccessPolicy (ExchangePowerShell) | Microsoft Docs

Disable user browsing in Azure Active Directory for standard users

I created a new AAD user without any special permissions (no admin, just a user). Now, when I login using the Connect-MSOLService cmdlet and retrieve all users using Get-MSOLUser I can see every user within that directory.
Why and am I able to change that?
Background: I want to use a single AAD instance for multiple SAAS applications and want to prevent that a user can browse all users.
Actually, there is a way to disable user browsing in an AAD using the Set-MsolCompanySettings from the MSOnline module:
Set-MsolCompanySettings -UsersPermissionToReadOtherUsersEnabled $false
In Azure AD, Users and groups are created in a flat structure without OU and GPO. You can't restrict the user's permission to a specific scope. The user can view all the user information in Azure AD.
To isolate the users from different scopes, you can create multiple directories for Azure AD, and configure the SaaS applications as multi-tenant application for AAD.
You can refer to the article below for more details about Azure AD Directory role.
https://learn.microsoft.com/en-us/azure/active-directory/active-directory-assign-admin-roles
If you connect to an Active Directory you usually want to read some data. As such if you're authorized to do that you can easily access information that is available and particularly "sensitive" (e.g. you can't read private keys of user objects easily). If you look at the history of Active Directory and it's typical usage within companies, it's likely that only single tenant (company) using it at a given time. As such there were even less reason to restrict the access.
If you want to have multiple tenants use the same AD you will have to figure out a scheme that works for you and setup the proper permissions yourself.
Helpful articles for this could be:
Build a multi-tenant SaaS web application using Azure AD & OpenID Connect
Question: Creating a multi-tenant AD environment

What is endpoint to access a user's Office 365 group using Microsoft Graph API?

I am using https://graph.microsoft.com/v1.0/groups but it needs admin privilege. Does anyone know how to get the groups assigned to sign-in user?
For an app to read or manage an Office 365 group, it does require an administrator to grant those permissions to the application. Once granted, the app can query for the O365 groups that the signed in user is a member of. For more information please see the scenarios section in the permissions topic here: https://graph.microsoft.io/en-us/docs/authorization/permission_scopes#permission-scope-scenarios.
Also the front page overview of the Microsoft Graph documentation has a table with common queries: https://graph.microsoft.io/en-us/docs/overview/overview. The one you want (to get the groups for the signed in user) is:
GET https://graph.microsoft.com/v1.0/me/memberOf/$/microsoft.graph.group?$filter=groupTypes/any(a:a%20eq%20'unified')
Hope this helps,

How to migrate memberships from SqlAzureMembershipProvider to Azure Active Directory

I have an existing application with a few thousand users using SqlAzureMembershipProvider for authentication.
I am interested in creating an Azure Active Directory for the application and migrating the existing membership profiles into it.
Is it technically possible to export/import the membership profiles?
The only approach I can think of is creating a PowerShell script that gets user details from the app one by one and creates a new user for each of those in the new AD.
Yes it is possible but there are no tools to do this.
For AD e.g. there is DirSync.
Probably easiest to use the Graph API - refer: Azure AD Graph API - samples Microsoft Azure Active Directory Samples and Documentation.
As you say, you will have to cycle through the users one by one. The password is going to be a problem. You may have to give each user a dummy password to start.