Programmatically removing the checkbox "Enable inheritable permissions from this parent of the object" using C #

I have a requirement in my application to iterate over all subfolders programmatically removing the checkbox "Include inheritable permissions from this parent object" using C #. enter image description here

And also convert and add the inherited parent permissions as explicit permissions for the folder.

Can anyone tell me? how can i do this in c #

+2
source share
1 answer

You need to use ObjectSecurity.SetAccessRuleProtection :

 string path = @"..."; FileSecurity fs = File.GetAccessControl(path); fs.SetAccessRuleProtection(true, false); File.SetAccessControl(path, fs); 
+3
source

Source: https://habr.com/ru/post/912810/


All Articles