我在 ACL 中为我的文件夹添加了组,但我无法检查/取消它的选项。
String account = @"HYPROSTROY\Все сотрудники";
FileSystemRights rights = FileSystemRights.FullControl;
// I have tried and it too:
// FileSystemRights rights = FileSystemRights.Read | FileSystemRights.Write | FileSystemRights.Modify;
AccessControlType controlType = AccessControlType.Allow;
DirectorySecurity security = local_commonDir.Parent.GetAccessControl(AccessControlSections.Access);
FileSystemAccessRule rule = new FileSystemAccessRule(account, rights, controlType);
security.AddAccessRule(rule);
// local_commonDir - экземпляр DirectoryInfo
local_commonDir.Parent.SetAccessControl(security);
添加了组,但未选中所有选项:
UPD ===我尝试了其他方法:
// String account = Path.Combine(Environment.MachineName, "Пользователи");
String account = @"HYPROSTROY\Все сотрудники";
FileSystemRights rights = FileSystemRights.FullControl;
AccessControlType controlType = AccessControlType.Allow;
DirectorySecurity security = local_commonDir.Parent.GetAccessControl(AccessControlSections.All);
FileSystemAccessRule rule = new FileSystemAccessRule(account, rights, controlType);
//security.AddAccessRule(rule);
Boolean result;
security.ModifyAccessRule(AccessControlModification.Add, rule, out result);
local_commonDir.Parent.SetAccessControl(security);
但选项未选中:(
我的错误在哪里?