2011-01-24 266 views
3

當我在資源管理器屬性窗口中瀏覽權限時,爲什麼以下訪問規則顯示爲「特殊權限」?我希望它看起來像一個正常的「修改」訪問。文件夾權限

var di = new DirectoryInfo(ConfigDirectory); 
DirectorySecurity security = di.GetAccessControl(); 
var rule = new FileSystemAccessRule(domainSid, FileSystemRights.Modify, AccessControlType.Allow); 
security.AddAccessRule(rule); 
di.SetAccessControl(security); 

domainSid =域用戶的SID。

  1. 如何創建規則,使其由該文件夾中創建的所有文件繼承?

回答

2

使用這個代替:

var di = new DirectoryInfo(ConfigDirectory); 
DirectorySecurity security = di.GetAccessControl(); 
var rule = new FileSystemAccessRule(domainSid, FileSystemRights.Modify, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow); 
security.AddAccessRule(rule); 
security.SetAccessRule(rule); 
di.SetAccessControl(security); 

使用FileSystemAccessRule構造,使您可以specifiy繼承和調用security.SetAccessRule(rule);

的區別