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); } }
public DirectorySecurity GetAccessControl(AccessControlSections includeSections) => Directory.GetAccessControl(this.FullPath, includeSections);
public DirectorySecurity GetAccessControl() => Directory.GetAccessControl(this.FullPath);
public DirectorySecurity GetAccessControl(AccessControlSections includeSections) { return(Directory.GetAccessControl(FullPath, includeSections)); }
public DirectorySecurity GetAccessControl() { return(Directory.GetAccessControl(FullPath)); }