Azure AD Guest User Access Restrictions mit PowerShell konfigurieren

Die Konfiguration mit welchem Level Gastkonten Zugriff auf interne Informationen im Tenant erhalten lässt sich über Microsoft Graph setzen. Ein Beispiel zur Konfiguration mit PowerShell.

Abhängig zur Konfiguration in Azure AD können Gastkonten Daten von internen Konten auswerten. In Azure AD > External Identities > External Collaboration Settings gibt es 3 mögliche Konfiguration.

  • Most inclusive
  • Limited access (Standardkonfiguration für neue Tenants)
  • Most restrictive

Beispiele wie sich die Konfigurationen beim Zugriff über PowerShell auswirken zeigte ich im Januar.
Die 3 möglichen Konfigurationen sind über die Microsoft Graph API authorizationPolicy anpassbar. Das beschriebene Property guestUserRoleId inkludiert Details über die 3 Guids für die Konfiguration.

Represents role templateId for the role that should be granted to guest user. Currently following roles are supported: User (a0b1b346-4d3e-4e8b-98f8-753987be4970), Guest User (10dae51f-b6af-4016-8d66-8c2a99b929b3), and Restricted Guest User (2af84b1e-32c8-42b7-82bc-daa82404023b).

  • Most inclusive = a0b1b346-4d3e-4e8b-98f8-753987be4970
  • Limited access = 10dae51f-b6af-4016-8d66-8c2a99b929b3
  • Most restrictive = 2af84b1e-32c8-42b7-82bc-daa82404023b

Über eine Azure App Registration mit der Berechtigung Policy.ReadWrite.Authorization ist die Anpassung möglich. Hier eine Hilfe zur Erstellung der App.

  1. Über mein Command Get-TAMSAuthToken hole ich mir einen Token zur Authentifizierung.
Import-module TAMPowerShell
$AuthHeader = Get-TAMSAuthToken -AppID [AppID] -ClientSecret [ClientSecret] -Tenantname "[Tenantname].onmicrosoft.com" -API Graph -PermissionType Application -ReturnAuthHeader
  1. Für die Anpassung bilde ich mir einen Body mit der Guid für “most restrictive”.
$Body = @"
{ "guestUserRoleId": "2af84b1e-32c8-42b7-82bc-daa82404023b" }
"@
  1. Die Anpassung mit der authorizationPolicy API erfolgt über eine Patch-Methode.
$Url = "https://graph.microsoft.com/v1.0/policies/authorizationPolicy"
Invoke-RestMethod -Method Patch -Headers $AuthHeader -Uri $Url -Body $Body -ContentType 'application/json'
  1. Über die Get-Methode wird das Ergebnis überprüft.
$Results = Invoke-RestMethod -Method Get -Headers $AuthHeader -Uri $Url -ContentType 'application/json'
$Results

Das Ergebnis inkludiert bei guestUserRoleId die neue Guid für “most restrictive”.

Eine Kontrolle in Azure AD zeigt die Konfiguration wurde auf “most restrictive” geändert.

Share
Avatar photo

Tobias Asböck

Tobias is a Senior System Engineer with more than 10 years of professional experience with Microsoft 365 products such as SharePoint Online, SharePoint Premium, OneDrive for Business, Teams Collaboration, Entra ID, Information Protection, Universal Print, and Microsoft 365 Licensing. He also has 15+ years of experience planning, administering, and operating SharePoint Server environments. Tobias is a PowerShell Scripter with certifications for Microsoft 365 products. In his spare time, Tobias is busy with updates in the Microsoft 365 world or on the road with his road bike and other sports activities. If you have additional questions, please contact me via LinkedIn or [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *