Skip to content

Commit abf66b2

Browse files
changes after review
1 parent 3ab92a5 commit abf66b2

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

permissions/groups/subPermissions.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
# Enable TLS1.2
77
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
88

9+
# Script Mapping lookup values
10+
$contractCorrelationField = 'displayName'
11+
$contractCorrelationValue = { $_.custom.SDBGroupName }
12+
913
# Determine all the sub-permissions that needs to be Granted/Updated/Revoked
1014
$currentPermissions = @{}
1115
foreach ($permission in $actionContext.CurrentPermissions) {
1216
$currentPermissions[$permission.Reference.Id] = $permission.DisplayName
1317
}
1418

15-
#region functions
19+
#region functions
1620
function Resolve-SDB-IdentityError {
1721
[CmdletBinding()]
1822
param (
@@ -75,11 +79,9 @@ try {
7579
}
7680
}
7781

78-
if ($null -ne $correlatedAccount) {
79-
$accountFound = $true
80-
} else {
81-
$accountFound = $false
82-
}
82+
if ($null -eq $correlatedAccount) {
83+
throw 'NotFound'
84+
}
8385

8486
Write-Information 'Retrieving permissions'
8587
$count = 100
@@ -117,9 +119,8 @@ try {
117119
Write-Information "Contract: $($contract.ExternalId). In condition: $($contract.Context.InConditions)"
118120
if ($contract.Context.InConditions -OR ($actionContext.DryRun -eq $true)) {
119121
# Get group to use objectGuid to avoid name change issues
120-
$correlationField = "displayName"
121-
# Example: department_<department externalId>
122-
$correlationValue = $contract.custom.SDBGroupName
122+
$correlationField = $contractCorrelationField
123+
$correlationValue = $contractCorrelationValue
123124

124125
$group = $null
125126
$group = $groupsGrouped["$($correlationValue)"]

resources/resource.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# Enable TLS1.2
88
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
99

10+
# Script Mapping lookup values
11+
$resourceCorrelationField = "externalId"
12+
$resourceCorrelationValue = { $($resource.ExternalId) }
13+
1014
#region functions
1115
function Resolve-SDB-IdentityError {
1216
[CmdletBinding()]
@@ -133,8 +137,8 @@ try {
133137
#region get group for resource
134138
$actionMessage = "querying group for resource: $($resource | ConvertTo-Json)"
135139

136-
$correlationField = "externalId"
137-
$correlationValue = "$($resource.ExternalId)"
140+
$correlationField = $resourceCorrelationField
141+
$correlationValue = $resourceCorrelationValue
138142

139143
$correlatedResource = $null
140144
$correlatedResource = $groupsGrouped["$($correlationValue)"]

0 commit comments

Comments
 (0)