Skip to content

Commit ed2aae8

Browse files
authored
Merge pull request #632 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 15efd2a + d79fc49 commit ed2aae8

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Modules/CIPPCore/Public/Authentication/Test-CIPPAccess.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ function Test-CIPPAccess {
1717
$CIPPCoreModule = Get-Module -Name CIPPCore
1818
if ($CIPPCoreModule) {
1919
$PermissionsFileJson = Join-Path $CIPPCoreModule.ModuleBase 'lib' 'data' 'function-permissions.json'
20-
20+
2121
if (Test-Path $PermissionsFileJson) {
2222
try {
2323
$jsonData = Get-Content -Path $PermissionsFileJson -Raw | ConvertFrom-Json -AsHashtable
2424
$global:CIPPFunctionPermissions = [System.Collections.Hashtable]::new([StringComparer]::OrdinalIgnoreCase)
2525
foreach ($key in $jsonData.Keys) {
2626
$global:CIPPFunctionPermissions[$key] = $jsonData[$key]
2727
}
28-
Write-Information "Loaded $($global:CIPPFunctionPermissions.Count) function permissions from JSON cache"
28+
Write-Debug "Loaded $($global:CIPPFunctionPermissions.Count) function permissions from JSON cache"
2929
} catch {
3030
Write-Warning "Failed to load function permissions from JSON: $($_.Exception.Message)"
3131
}
@@ -41,13 +41,13 @@ function Test-CIPPAccess {
4141
$PermissionData = $global:CIPPFunctionPermissions[$FunctionName]
4242
$APIRole = $PermissionData['Role']
4343
$Functionality = $PermissionData['Functionality']
44-
Write-Information "Loaded function permission data from cache for '$FunctionName': Role='$APIRole', Functionality='$Functionality'"
44+
Write-Debug "Loaded function permission data from cache for '$FunctionName': Role='$APIRole', Functionality='$Functionality'"
4545
} else {
4646
try {
4747
$Help = Get-Help $FunctionName -ErrorAction Stop
4848
$APIRole = $Help.Role
4949
$Functionality = $Help.Functionality
50-
Write-Information "Loaded function permission data via Get-Help for '$FunctionName': Role='$APIRole', Functionality='$Functionality'"
50+
Write-Debug "Loaded function permission data via Get-Help for '$FunctionName': Role='$APIRole', Functionality='$Functionality'"
5151
} catch {
5252
Write-Warning "Function '$FunctionName' not found"
5353
}

Modules/CIPPCore/Public/Functions/Get-CIPPTenantAlignment.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,27 @@ function Get-CIPPTenantAlignment {
111111

112112
if ($Template.tenantFilter -and $Template.tenantFilter.Count -gt 0) {
113113
# Extract tenant values from the tenantFilter array
114-
$TenantValues = $Template.tenantFilter | ForEach-Object {
115-
if ($_.type -eq 'group') {
116-
($TenantGroups | Where-Object -Property GroupName -EQ $_.value).Members.defaultDomainName
114+
$TenantValues = [System.Collections.Generic.List[string]]::new()
115+
foreach ($filterItem in $Template.tenantFilter) {
116+
if ($filterItem.type -eq 'group') {
117+
# Look up group members by Id (GUID in the value field)
118+
$GroupMembers = $TenantGroups | Where-Object { $_.Id -eq $filterItem.value }
119+
if ($GroupMembers -and $GroupMembers.Members) {
120+
foreach ($member in $GroupMembers.Members.defaultDomainName) {
121+
$TenantValues.Add($member)
122+
}
123+
}
117124
} else {
118-
$_.value
125+
$TenantValues.Add($filterItem.value)
119126
}
120127
}
121128

122129
if ($TenantValues -contains 'AllTenants') {
123130
$AppliestoAllTenants = $true
131+
} elseif ($TenantValues.Count -gt 0) {
132+
$TemplateAssignedTenants = @($TenantValues)
124133
} else {
125-
$TemplateAssignedTenants = $TenantValues
134+
$TemplateAssignedTenants = @()
126135
}
127136
} else {
128137
$AppliestoAllTenants = $true

0 commit comments

Comments
 (0)