Skip to content

Commit 6b51c0b

Browse files
author
Horacio Fernandez
committed
Update
1 parent 57585ec commit 6b51c0b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

PowerShellAccessControl.psd1

0 Bytes
Binary file not shown.

PowerShellAccessControl.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ can be used to provide AuditFlags and Inheritance/Propagation flags (WMI ACE obj
251251

252252
#region Get Inheritance and Propagation flags
253253
if (-not $PSBoundParameters.ContainsKey("AppliesTo")) {
254-
if ($PSBoundParameters.ContainsKey("AceFlags") -and $AceFlags -band [System.Security.AccessControl.AceFlags]::InheritanceFlags) {
254+
if ($PSBoundParameters.ContainsKey("AceFlags") -and $AceFlags.value__ -band [System.Security.AccessControl.AceFlags]::InheritanceFlags.value__) {
255255
# AceFlags contains inheritance/propagation info, so get the AppliesTo from that
256256
$InheritanceFlags = $PropagationFlags = 0
257257
foreach ($CurrentFlag in "ContainerInherit", "ObjectInherit") {
258-
if ($AceFlags -band [System.Security.AccessControl.AceFlags]::$CurrentFlag) {
258+
if ($AceFlags.value__ -band ([int][System.Security.AccessControl.AceFlags]::$CurrentFlag)) {
259259
$InheritanceFlags = $InheritanceFlags -bor [System.Security.AccessControl.InheritanceFlags]::$CurrentFlag
260260
}
261261
}
262262
foreach ($CurrentFlag in "NoPropagateInherit","InheritOnly") {
263-
if ($AceFlags -band [System.Security.AccessControl.AceFlags]::$CurrentFlag) {
263+
if ($AceFlags.value__ -band ([int][System.Security.AccessControl.AceFlags]::$CurrentFlag)) {
264264
$PropagationFlags = $PropagationFlags -bor [System.Security.AccessControl.PropagationFlags]::$CurrentFlag
265265
}
266266
}
@@ -315,8 +315,8 @@ can be used to provide AuditFlags and Inheritance/Propagation flags (WMI ACE obj
315315

316316
# Or Success/Failure audits may have been specified through AceFlags (usually happens
317317
# when another ACE is fed to New-AccessControlEntry through pipeline.
318-
if ($PSBoundParameters.AceFlags -band [System.Security.AccessControl.AceFlags]::SuccessfulAccess) { $AuditFlags += "Success" }
319-
if ($PSBoundParameters.AceFlags -band [System.Security.AccessControl.AceFlags]::FailedAccess) { $AuditFlags += "Failure" }
318+
if ([int] $PSBoundParameters.AceFlags -band [System.Security.AccessControl.AceFlags]::SuccessfulAccess) { $AuditFlags += "Success" }
319+
if ([int] $PSBoundParameters.AceFlags -band [System.Security.AccessControl.AceFlags]::FailedAccess) { $AuditFlags += "Failure" }
320320

321321
if ($AuditFlags) {
322322
$AuditFlags = $AuditFlags -as [System.Security.AccessControl.AuditFlags]

PowerShellAccessControlHelperFunctions.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ etc.
530530
# Get a copy of the rule (we don't want to touch the original object)
531531
Write-Debug "$($MyInvocation.MyCommand): No conversion necessary"
532532
$Rule = $Rule.Copy()
533-
$IsRuleInherited = [bool] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited)
533+
$IsRuleInherited = [bool] ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited.value__)
534534
break
535535
}
536536

@@ -618,7 +618,7 @@ etc.
618618
($_ -eq "Microsoft.Management.Infrastructure.CimInstance" -and
619619
($Rule.CimClass.CimClassName -eq "Win32_ACE") -or ($Rule.CimClass.CimClassName -eq "__ACE")) } {
620620

621-
$IsRuleInherited = [bool] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited)
621+
$IsRuleInherited = [bool] ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited.value__)
622622

623623
# Long and scary looking condition, but it just means do the
624624
# following if it's a WMI object of the Win32_ACE class
@@ -643,8 +643,8 @@ etc.
643643

644644
if ($Rule.AceType -eq [System.Security.AccessControl.AceQualifier]::SystemAudit) {
645645
# Not an access entry, but an audit entry
646-
$Params.AuditSuccess = [bool] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::SuccessfulAccess)
647-
$Params.AuditFailure = [bool] ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::FailedAccess)
646+
$Params.AuditSuccess = [bool] ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::SuccessfulAccess.value__)
647+
$Params.AuditFailure = [bool] ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::FailedAccess.value__)
648648
}
649649

650650
# Make the rule:
@@ -666,14 +666,14 @@ etc.
666666
# it's usually to add or remove an ACE. In either of those
667667
# scenarios, you don't want the resulting ACE to still be
668668
# inherited, so remove that flag if it's present
669-
if ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited) {
670-
$Rule.AceFlags = $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags]::Inherited
669+
if ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited.value__) {
670+
$Rule.AceFlags = [int] $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags]::Inherited.value__
671671
}
672672
}
673673
else {
674-
if ($IsRuleInherited -and (-not ($Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited))) {
674+
if ($IsRuleInherited -and (-not ([int] $Rule.AceFlags -band [System.Security.AccessControl.AceFlags]::Inherited.value__))) {
675675
# If the original rule was inherited, but the converted one isn't, fix it!
676-
$Rule.AceFlags = $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags]::Inherited
676+
$Rule.AceFlags = [int] $Rule.AceFlags -bxor [System.Security.AccessControl.AceFlags]::Inherited.value__
677677
}
678678
}
679679

0 commit comments

Comments
 (0)