Skip to content

Commit

Permalink
Merge pull request #1255 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
JohnDuprey authored Jan 22, 2025
2 parents 7ccd2b8 + 2366c44 commit f794212
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ function Get-CIPPRolePermissions {
$Role = Get-CIPPAzDataTableEntity @Table -Filter $Filter
if ($Role) {
$Permissions = $Role.Permissions | ConvertFrom-Json
$AllowedTenants = if ($Role.AllowedTenants) { $Role.AllowedTenants | ConvertFrom-Json } else { @() }
$BlockedTenants = if ($Role.BlockedTenants) { $Role.BlockedTenants | ConvertFrom-Json } else { @() }
[PSCustomObject]@{
Role = $Role.RowKey
Permissions = $Permissions.PSObject.Properties.Value
AllowedTenants = if ($Role.AllowedTenants) { $Role.AllowedTenants | ConvertFrom-Json } else { @() }
BlockedTenants = if ($Role.BlockedTenants) { $Role.BlockedTenants | ConvertFrom-Json } else { @() }
AllowedTenants = @($AllowedTenants)
BlockedTenants = @($BlockedTenants)
}
} else {
throw "Role $RoleName not found."
}
}
}
6 changes: 3 additions & 3 deletions Modules/CIPPCore/Public/Authentication/Test-CIPPAccess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function Test-CIPPAccess {
if ($PermissionsFound) {
if ($TenantList.IsPresent) {
$LimitedTenantList = foreach ($Permission in $PermissionSet) {
if (($Permission.AllowedTenants | Measure-Object).Count -eq 0 -and ($Permission.BlockedTenants | Measure-Object).Count -eq 0) {
return @('AllTenants')
if ((($Permission.AllowedTenants | Measure-Object).Count -eq 0 -or $Permission.AllowedTenants -contains 'AllTenants') -and (($Permission.BlockedTenants | Measure-Object).Count -eq 0)) {
@('AllTenants')
} else {
if ($Permission.AllowedTenants -contains 'AllTenants') {
$Permission.AllowedTenants = $Tenants.customerId
Expand Down Expand Up @@ -135,4 +135,4 @@ function Test-CIPPAccess {
} else {
return $true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ Function Invoke-ListSites {
url = "sites/$($Site.siteId)/lists?`$select=id,name,list,parentReference"
}
}
$Requests = (New-GraphBulkRequest -tenantid $TenantFilter -scope 'https://graph.microsoft.com/.default' -Requests @($Requests) -asapp $true).body.value | Where-Object { $_.list.template -eq 'DocumentLibrary' }
try {
$Requests = (New-GraphBulkRequest -tenantid $TenantFilter -scope 'https://graph.microsoft.com/.default' -Requests @($Requests) -asapp $true).body.value | Where-Object { $_.list.template -eq 'DocumentLibrary' }
} catch {
Write-LogMessage -Message "Error getting auto map urls: $($_.Exception.Message)" -Sev 'Error' -tenant $TenantFilter -API 'ListSites' -LogData (Get-CippException -Exception $_)
}
$GraphRequest = foreach ($Site in $GraphRequest) {
$ListId = ($Requests | Where-Object { $_.parentReference.siteId -like "*$($Site.siteId)*" }).id
$site.AutoMapUrl = "tenantId=$($TenantId)&webId={$($Site.webId)}&siteid={$($Site.siteId)}&webUrl=$($Site.webUrl)&listId={$($ListId)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Function Invoke-ListTenants {

Write-LogMessage -user $Request.Headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$TenantAccess = Test-CIPPAccess -Request $Request -TenantList
Write-Host "Tenant Access: $TenantAccess"

if ($TenantAccess -notcontains 'AllTenants') {
$AllTenantSelector = $false
Expand Down
1 change: 1 addition & 0 deletions Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function Get-Tenants {
} catch {
$ErrorMessage = Get-CippException -Exception $_
Write-LogMessage -API 'Get-Tenants' -message "Tried adding $($LatestRelationship.customerId) to tenant list but failed to get domains - $($_.Exception.Message)" -Sev 'Critical' -LogData $ErrorMessage
$Domain = 'Invalid'
} finally {
$defaultDomainName = $Domain
$initialDomainName = $Domain
Expand Down

0 comments on commit f794212

Please sign in to comment.