forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
33 additions
and
45 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
Modules/CIPPCore/Public/Entrypoints/Push-UpdatePermissionsQueue.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function Push-UpdatePermissionsQueue { | ||
# Input bindings are passed in via param block. | ||
param($Item) | ||
Write-Host "Applying permissions for $($Item.defaultDomainName)" | ||
$Table = Get-CIPPTable -TableName cpvtenants | ||
$CPVRows = Get-CIPPAzDataTableEntity @Table | Where-Object -Property Tenant -EQ $Item.customerId | ||
if (!$CPVRows -or $ENV:ApplicationID -notin $CPVRows.applicationId) { | ||
Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message 'A New tenant has been added, or a new CIPP-SAM Application is in use' -Sev 'Warn' -API 'NewTenant' | ||
Write-Host 'Adding CPV permissions' | ||
Set-CIPPCPVConsent -Tenantfilter $Item.defaultDomainName | ||
} | ||
|
||
Add-CIPPApplicationPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.defaultDomainName | ||
Add-CIPPDelegatedPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.defaultDomainName | ||
|
||
Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message "Updated permissions for $($Item.defaultDomainName)" -Sev 'Info' -API 'UpdatePermissionsQueue' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# Input bindings are passed in via param block. | ||
param($Timer) | ||
|
||
$Tenants = get-tenants -IncludeErrors | Where-Object { $_.customerId -ne $env:TenantId } | ||
foreach ($Row in $Tenants) { | ||
Push-OutputBinding -Name Msg -Value $row | ||
} | ||
try { | ||
$Tenants = Get-Tenants -IncludeErrors | Where-Object { $_.customerId -ne $env:TenantId } | ForEach-Object { $_ | Add-Member -NotePropertyName FunctionName -NotePropertyValue 'UpdatePermissionsQueue'; $_ } | ||
|
||
if (($Tenants | Measure-Object).Count -gt 0) { | ||
$InputObject = [PSCustomObject]@{ | ||
OrchestratorName = 'UpdatePermissionsOrchestrator' | ||
Batch = @($Tenants) | ||
} | ||
#Write-Host ($InputObject | ConvertTo-Json) | ||
$InstanceId = Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5) | ||
Write-Host "Started permissions orchestration with ID = '$InstanceId'" | ||
} | ||
} catch {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.