public void Init() { currentUser = WindowsIdentity.GetCurrent().User; currentUser2 = WindowsIdentity.GetCurrent().User; systemAccount = new IdentityReference2(@"NT AUTHORITY\SYSTEM"); invalidSid = "S-1-5-2-123456789-2021496291-1752113662-1002"; }
static void Main(string[] args) { var item1 = new FileInfo("D:\\file1.txt"); var item2 = new DirectoryInfo("D:\\test3"); var account1 = new List <IdentityReference2>() { (IdentityReference2)@"raandree1\randr_000" }; FileSystemAccessRule2.AddFileSystemAccessRule(item1, account1, FileSystemRights2.FullControl, AccessControlType.Allow, InheritanceFlags.ContainerInherit, PropagationFlags.None); return; var path = @"C:\Windows"; var account = @"raandree1\randr_000"; var server = "localhost"; var sd = Directory.GetAccessControl(path, AccessControlSections.Access); var id = new IdentityReference2(account); EffectiveAccess.GetEffectiveAccess(new FileInfo(path), id, "localhost"); var result1 = InvokeCommand("gi2 c:\\windows"); var result2 = InvokeCommand(@"gi -Path D:\SingleMachine\ | Get-EffectiveAccess") .Select(ace => ace.ImmediateBaseObject) .Cast <FileSystemAccessRule2>().ToList(); foreach (var ace in result2) { Console.WriteLine(string.Format("{0};{1}", ace.Account, ace.IsInherited)); } Console.ReadKey(); }
public void EqualsToNullThrowsException() { IdentityReference2 ir2 = null; ir2.Equals(null); }