mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
win_acl: registry support for special service accounts (#26629)
* Fixes #22968 * `APPLICATION PACKAGE AUTHORITY` ACLs also apply to the registry * fixed nested for loop
This commit is contained in:
parent
6de119ed3e
commit
81c22522a5
1 changed files with 16 additions and 21 deletions
|
@ -279,32 +279,27 @@ Try {
|
||||||
|
|
||||||
# Check if the ACE exists already in the objects ACL list
|
# Check if the ACE exists already in the objects ACL list
|
||||||
$match = $false
|
$match = $false
|
||||||
If ($path -match "^HK(CC|CR|CU|LM|U):\\") {
|
|
||||||
ForEach($rule in $objACL.Access){
|
# Workaround to handle special use case 'APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES' and
|
||||||
|
# 'APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES'- can't translate fully qualified name (win32 API bug/oddity)
|
||||||
|
# 'ALL APPLICATION PACKAGES' exists only on Win2k12 and Win2k16 and 'ALL RESTRICTED APPLICATION PACKAGES' exists only in Win2k16
|
||||||
|
$specialIdRefs = "ALL APPLICATION PACKAGES","ALL RESTRICTED APPLICATION PACKAGES"
|
||||||
|
ForEach($rule in $objACL.Access){
|
||||||
|
$idRefShortValue = ($rule.IdentityReference.Value).split('\')[-1]
|
||||||
|
|
||||||
|
if ( $idRefShortValue -in $specialIdRefs ) {
|
||||||
|
$ruleIdentity = (New-Object Security.Principal.NTAccount $idRefShortValue).Translate([Security.Principal.SecurityIdentifier])
|
||||||
|
}
|
||||||
|
else {
|
||||||
$ruleIdentity = $rule.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier])
|
$ruleIdentity = $rule.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier])
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($path -match "^HK(CC|CR|CU|LM|U):\\") {
|
||||||
If (($rule.RegistryRights -eq $objACE.RegistryRights) -And ($rule.AccessControlType -eq $objACE.AccessControlType) -And ($ruleIdentity -eq $objACE.IdentityReference) -And ($rule.IsInherited -eq $objACE.IsInherited) -And ($rule.InheritanceFlags -eq $objACE.InheritanceFlags) -And ($rule.PropagationFlags -eq $objACE.PropagationFlags)) {
|
If (($rule.RegistryRights -eq $objACE.RegistryRights) -And ($rule.AccessControlType -eq $objACE.AccessControlType) -And ($ruleIdentity -eq $objACE.IdentityReference) -And ($rule.IsInherited -eq $objACE.IsInherited) -And ($rule.InheritanceFlags -eq $objACE.InheritanceFlags) -And ($rule.PropagationFlags -eq $objACE.PropagationFlags)) {
|
||||||
$match = $true
|
$match = $true
|
||||||
Break
|
Break
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
Else {
|
|
||||||
# Workaround to handle special use case 'APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES' and
|
|
||||||
# 'APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES'- can't translate fully qualified name (win32 API bug/oddity)
|
|
||||||
# 'ALL APPLICATION PACKAGES' exists only on Win2k12 and Win2k16 and 'ALL RESTRICTED APPLICATION PACKAGES' exists only in Win2k16
|
|
||||||
|
|
||||||
$specialIdRefs = "ALL APPLICATION PACKAGES","ALL RESTRICTED APPLICATION PACKAGES"
|
|
||||||
|
|
||||||
ForEach($rule in $objACL.Access){
|
|
||||||
|
|
||||||
$idRefShortValue = ($rule.IdentityReference.Value).split('\')[-1]
|
|
||||||
|
|
||||||
if ( $idRefShortValue -in $specialIdRefs ) {
|
|
||||||
$ruleIdentity = (New-Object Security.Principal.NTAccount $idRefShortValue).Translate([Security.Principal.SecurityIdentifier])
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ruleIdentity = $rule.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier])
|
|
||||||
}
|
|
||||||
If (($rule.FileSystemRights -eq $objACE.FileSystemRights) -And ($rule.AccessControlType -eq $objACE.AccessControlType) -And ($ruleIdentity -eq $objACE.IdentityReference) -And ($rule.IsInherited -eq $objACE.IsInherited) -And ($rule.InheritanceFlags -eq $objACE.InheritanceFlags) -And ($rule.PropagationFlags -eq $objACE.PropagationFlags)) {
|
If (($rule.FileSystemRights -eq $objACE.FileSystemRights) -And ($rule.AccessControlType -eq $objACE.AccessControlType) -And ($ruleIdentity -eq $objACE.IdentityReference) -And ($rule.IsInherited -eq $objACE.IsInherited) -And ($rule.InheritanceFlags -eq $objACE.InheritanceFlags) -And ($rule.PropagationFlags -eq $objACE.PropagationFlags)) {
|
||||||
$match = $true
|
$match = $true
|
||||||
Break
|
Break
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue