dsccommunity / ActiveDirectoryDsc

This module contains DSC resources for deployment and configuration of Active Directory Domain Services.
MIT License
344 stars 142 forks source link

ADObjectPermissionEntry: Allow Permission updates without using a Domain Admin account #576

Closed JasonN3 closed 4 years ago

JasonN3 commented 4 years ago

Pull Request (PR) description

This pull request is to fix an issue where the DSC module must be run as a Domain Admin in order to update an objects permissions.

This Pull Request (PR) fixes the following issues

Task list


This change is Reviewable

JasonN3 commented 4 years ago

Tests run using a non-DA account:

Add Access (Result = Access granted)

Set-TargetResource -Ensure Present -ObjectType '00000000-0000-0000-0000-000000000000' -InheritedObjectType '00000000-0000-0000-0000-000000000000' -Path $ObjectDN -IdentityReference "${DOMAIN}\${ACCOUNT}" -ActiveDirectoryRights GenericAll -AccessControlType Allow -ActiveDirectorySecurityInheritance None

Add Access a second time (Result = No action taken)

Set-TargetResource -Ensure Present -ObjectType '00000000-0000-0000-0000-000000000000' -InheritedObjectType '00000000-0000-0000-0000-000000000000' -Path $ObjectDN -IdentityReference "${DOMAIN}\${ACCOUNT}" -ActiveDirectoryRights GenericAll -AccessControlType Allow -ActiveDirectorySecurityInheritance None

$Update Permissions (Result = Access replaced) Set-TargetResource -Ensure Present -ObjectType '00000000-0000-0000-0000-000000000000' -InheritedObjectType '00000000-0000-0000-0000-000000000000' -Path $ObjectDN -IdentityReference "${DOMAIN}\${ACCOUNT}" -ActiveDirectoryRights GenericRead -AccessControlType Allow -ActiveDirectorySecurityInheritance None

Remove Access (Result = Access revoked)

Set-TargetResource -Ensure Absent -ObjectType '00000000-0000-0000-0000-000000000000' -InheritedObjectType '00000000-0000-0000-0000-000000000000' -Path $ObjectDN -IdentityReference "${DOMAIN}\${ACCOUNT}" -ActiveDirectoryRights GenericRead -AccessControlType Allow -ActiveDirectorySecurityInheritance None

Remove Access a second time (Result = No action taken)

Set-TargetResource -Ensure Absent -ObjectType '00000000-0000-0000-0000-000000000000' -InheritedObjectType '00000000-0000-0000-0000-000000000000' -Path $ObjectDN -IdentityReference "${DOMAIN}\${ACCOUNT}" -ActiveDirectoryRights GenericRead -AccessControlType Allow -ActiveDirectorySecurityInheritance None

JasonN3 commented 4 years ago

This fix breaks down when you use Invoke-DscResource and it goes through WinRM. I'm looking for another solution.

X-Guardian commented 4 years ago

Hi @J4yD4n, please look at the issue and complete the discussion on that before you end up spending your time on a PR that may not be needed.

JasonN3 commented 4 years ago

Apparently DSC gets around Set-Acl trying to rewrite all permissions and failing. I did a test with PsDscCredential and it somehow worked even though it shouldn't have. Sorry for the waste of time. If someone else comes across this problem, make sure PsDscCredential is set.