C# AddAccessRule for "This folder, subfolders and files"

2.8k views Asked by At

I have some code to apply permissions to a folder that works but it sets the folder permissions as 'Special' with it being applied as "This Folder and Files" where I need it to be applied as "This folder, subfolders and files". What am I doing wrong?

dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, ControlType));
1

There are 1 answers

0
Paul Talbot On BEST ANSWER

Try splitting it across two rules;

dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, ControlType));
dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, ControlType));