Csharp/CSharp Tutorial/File Directory Stream/FileSecurity — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:31, 26 мая 2010

Accessing file Access Rules

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
public class MainClass
{
    public static void Main()
    {
        FileSecurity acl = File.GetAccessControl(@"C:\Windows\");
        AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));
        foreach (AuthorizationRule rule in rules)
        {
            Console.WriteLine(rule.IdentityReference);
            FileSystemAccessRule accessRule = rule as FileSystemAccessRule;
            if (accessRule != null)
                Console.WriteLine("  ...{0}", accessRule.FileSystemRights);
        }
    }
}
NT AUTHORITY\SYSTEM
  ...FullControl
BUILTIN\Administrators
  ...FullControl
BUILTIN\Users
  ...ReadAndExecute, Synchronize