Собсвенно код:
public class StaticMembers
{
private static FileSystemAccessRule _everyOneAccaunt;
public static FileSystemAccessRule EveryOneAccaunt
{
get
{
if(_everyOneAccaunt == null)
{
string account = new SecurityIdentifier("S-1-1-0").Translate(typeof(NTAccount)).ToString();
_everyOneAccaunt = new FileSystemAccessRule(account, FileSystemRights.FullControl, AccessControlType.Allow);
}
return _everyOneAccaunt;
}
}
public static void SetAllAccessToObject(string path,ILog log)
{
try
{
if (File.Exists(path))
{
FileSecurity fsec = new FileSecurity(path, AccessControlSections.All);
fsec.AddAccessRule(EveryOneAccaunt);
File.SetAccessControl(path, fsec);
return;
}
if (Directory.Exists(path))
{
DirectorySecurity fsec = new DirectorySecurity(path, AccessControlSections.All);
fsec.AddAccessRule(EveryOneAccaunt);
Directory.SetAccessControl(path, fsec);
return;
}
}
catch (Exception ex)
{
log.Error("Ошибка смены прав", ex);
}
}
}
если использовать оное на директорию, то во вкладке безопасность появляется нужный акаунт (Все), только у него нету никаких прав. это фича или баг?