Здравствуйте, stump, Вы писали:
S>Здравствуйте, bpost, Вы писали:
B>>Уважаемый All. Есть ли возможность используя C# получить эффективные (действующие) права пользователя (группы пользователей) на сетевую папку ?
S>См. класс System.Security.AccessControl.DirectorySecurity
Вы не могли бы уточнить, как правильно воспользоваться в данной ситуации? У меня следующий код даёт не то
string NetDirName = @"\\ServerName\ShareName";
// string NetDirName = @"D:\Temp";
DirectoryInfo NetDirInfo = new DirectoryInfo(NetDirName);
AuthorizationRuleCollection Rules = null;
try
{
DirectorySecurity NetDirSec = NetDirInfo.GetAccessControl(AccessControlSections.Access);
Rules = NetDirSec.GetAccessRules(true, true, typeof(SecurityIdentifier));
// Rules = NetDirSec.GetAccessRules(true, true, typeof(NTAccount));
}
catch(UnauthorizedAccessException E)
{
Console.WriteLine("Exception: {0}\n", E.Message);
}
catch(Exception E)
{
Console.WriteLine("Exception: {0}\nMessage: {1}\n", E.GetType().Name, E.Message);
}
if (Rules != null)
{
Console.WriteLine("OK");
foreach (FileSystemAccessRule AR in Rules)
{
IdentityReference IR = AR.IdentityReference;
IdentityReference Account = IR.Translate(typeof(NTAccount));
Console.WriteLine(IR.Value);
Console.WriteLine(Account.Value + "\n");
// Console.WriteLine(Account.ToString());
IR = null;
Account = null;
}
}
На выходе получается DACL не сетевой шары, а объекта файловой системы, на котором она базируется.