Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADObjectPermissionEntry: Fix escaping issue when getting/setting ACLs #716

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)

- ActiveDirectoryDsc.Common
- Fixed Get-DomainControllerObject to allow checking non-local domain controller accounts.
- ADObjectPermissionEntry
- Fixed 'The object name has a bad syntax' error when using path that requires escaping.
([issue #675](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/675)).
- Update build process to pin GitVersion to 5.* to resolve errors
(https://github.com/gaelcolas/Sampler/issues/477).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function Get-TargetResource

try
{
# Get the current acl
$acl = Get-Acl -Path "AD:$Path" -ErrorAction Stop
# Get the current acl - include workaround for escaping paths https://github.com/dsccommunity/ActiveDirectoryDsc/issues/675
$acl = Get-Acl -Path "Microsoft.ActiveDirectory.Management.dll\ActiveDirectory:://RootDSE/$Path" -ErrorAction Stop
}
catch [System.Management.Automation.ItemNotFoundException]
{
Expand Down Expand Up @@ -209,8 +209,8 @@ function Set-TargetResource

Assert-ADPSDrive

# Get the current acl
$acl = Get-Acl -Path "AD:$Path"
# Get the current acl - include workaround for escaping paths https://github.com/dsccommunity/ActiveDirectoryDsc/issues/675
$acl = Get-Acl -Path "Microsoft.ActiveDirectory.Management.dll\ActiveDirectory:://RootDSE/$Path"

if ($Ensure -eq 'Present')
{
Expand Down Expand Up @@ -253,9 +253,9 @@ function Set-TargetResource
}
}

# Set the updated acl to the object
# Set the updated acl to the object - include workaround for escaping paths https://github.com/dsccommunity/ActiveDirectoryDsc/issues/675
$acl |
Set-Acl -Path "AD:$Path"
Set-Acl -Path "Microsoft.ActiveDirectory.Management.dll\ActiveDirectory:://RootDSE/$Path"
}

<#
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/MSFT_ADObjectPermissionEntry.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ try

$mockGetAclPresent = {
$mock = [PSCustomObject] @{
Path = 'AD:CN=PC01,CN=Computers,DC=contoso,DC=com'
Path = 'Microsoft.ActiveDirectory.Management.dll\ActiveDirectory:://RootDSE/CN=PC01,CN=Computers,DC=contoso,DC=com'
Owner = 'BUILTIN\Administrators'
Access = @(
[PSCustomObject] @{
Expand All @@ -84,7 +84,7 @@ try

$mockGetAclAbsent = {
$mock = [PSCustomObject] @{
Path = 'AD:CN=PC,CN=Computers,DC=lab,DC=local'
Path = 'Microsoft.ActiveDirectory.Management.dll\ActiveDirectory:://RootDSE/CN=PC,CN=Computers,DC=lab,DC=local'
Owner = 'BUILTIN\Administrators'
Access = @()
}
Expand Down