I have the following simple rule to give "Modify" permission on the directory:
File WorkerRoleContent
{
Ensure = "Present"
DestinationPath = $workerRoleContentDir
Type = "Directory"
}
xFileSystemAccessRule WorkerRoleContent
{
DependsOn = "[File]WorkerRoleContent"
Path = $workerRoleContentDir
Identity = $appUserName
Rights = "Modify"
Ensure = "Present"
}
When I apply this DSC configuration to clean system (no directory exists), everything works fine.
But when applying it on VM with already existing directory, I have the following error:
The security identifier is not allowed to be the owner of this object.
Googling a bit gave some results for Powershell Set-Acl cmdlet: http://www.mickputley.net/2015/11/set-acl-security-identifier-is-not.html
So, for now I implemented the following workaround using a Script resource:
Script WorkerRoleContent
{
DependsOn = "[File]WorkerRoleContent"
SetScript = {
$acl = (Get-Item $using:workerRoleContentDir).GetAccessControl('Access')
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($using:appUserName,
"Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.SetAccessRule($accessRule)
Set-ACL $using:workerRoleContentDir $acl
}
TestScript = {
return $false
}
GetScript = {
@{ Result = "WorkerRoleContent directory" }
}
}
As stated in refrenced article, main idea is to use (Get-Item $FolderPath).GetAccessControl('Access') instead of Get-ACL $FolderPath.
It seems like such fix must be used inside of xFileSystemAccessRule resource.
I have the following simple rule to give "Modify" permission on the directory:
When I apply this DSC configuration to clean system (no directory exists), everything works fine.
But when applying it on VM with already existing directory, I have the following error:
Googling a bit gave some results for Powershell Set-Acl cmdlet: http://www.mickputley.net/2015/11/set-acl-security-identifier-is-not.html
So, for now I implemented the following workaround using a
Scriptresource:As stated in refrenced article, main idea is to use
(Get-Item $FolderPath).GetAccessControl('Access')instead ofGet-ACL $FolderPath.It seems like such fix must be used inside of
xFileSystemAccessRuleresource.