예제 #1
0
        public void TestGetAccessControlSections()
        {
            var tempLongPathFilename = longPathDirectory.Combine(Pri.LongPath.Path.GetRandomFileName());

            tempLongPathFilename.CreateDirectory();

            try {
                var security = Directory.GetAccessControl(tempLongPathFilename, AccessControlSections.Access);
                Assert.IsNotNull(security);
                Assert.AreEqual(typeof(FileSystemRights), security.AccessRightType);
                Assert.AreEqual(typeof(FileSystemAccessRule), security.AccessRuleType);
                Assert.AreEqual(typeof(FileSystemAuditRule), security.AuditRuleType);
                Assert.IsTrue(security.AreAccessRulesCanonical);
                Assert.IsTrue(security.AreAuditRulesCanonical);
                Assert.IsFalse(security.AreAccessRulesProtected);
                Assert.IsFalse(security.AreAuditRulesProtected);
                var securityGetAccessRules = security.GetAuditRules(true, true, typeof(NTAccount)).Cast <FileSystemAccessRule>();
                Assert.AreEqual(0, securityGetAccessRules.Count());
                var perm      = security.GetAccessRules(true, true, typeof(NTAccount));
                var ntAccount = new NTAccount(WindowsIdentity.GetCurrent().Name);
                var rule      = perm.Cast <FileSystemAccessRule>().SingleOrDefault(e => ntAccount == e.IdentityReference);
                Assert.IsNotNull(rule);
                Assert.IsTrue((rule.FileSystemRights & FileSystemRights.FullControl) != 0);
            }
            finally {
                Directory.Delete(tempLongPathFilename);
            }
        }
예제 #2
0
 public DirectorySecurity GetAccessControl(AccessControlSections includeSections) => Directory.GetAccessControl(this.FullPath, includeSections);
예제 #3
0
 public DirectorySecurity GetAccessControl() => Directory.GetAccessControl(this.FullPath);
예제 #4
0
 public DirectorySecurity GetAccessControl(AccessControlSections includeSections)
 {
     return(Directory.GetAccessControl(FullPath, includeSections));
 }
예제 #5
0
 public DirectorySecurity GetAccessControl()
 {
     return(Directory.GetAccessControl(FullPath));
 }