programatically removing “Include inheritable permissions from this object's parent” checkbox using C#

烈酒焚心 提交于 2019-11-28 09:33:01

问题


I have a requirement in my application to iterate through all the sub-folders programatically removing "Include inheritable permissions from this object's parent" check box using C#.

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

Can any one let me know ? how can i do it in C#.


回答1:


You need to use ObjectSecurity.SetAccessRuleProtection:

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


来源:https://stackoverflow.com/questions/6574196/programatically-removing-include-inheritable-permissions-from-this-objects-par

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!