本文整理汇总了C#中System.Security.AccessControl.DiscretionaryAcl.RemoveInheritedAces方法的典型用法代码示例。如果您正苦于以下问题:C# DiscretionaryAcl.RemoveInheritedAces方法的具体用法?C# DiscretionaryAcl.RemoveInheritedAces怎么用?C# DiscretionaryAcl.RemoveInheritedAces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.AccessControl.DiscretionaryAcl
的用法示例。
在下文中一共展示了DiscretionaryAcl.RemoveInheritedAces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetectsCanonicalMergesAndRemovesInheritedAces
public void DetectsCanonicalMergesAndRemovesInheritedAces ()
{
SecurityIdentifier sid = new SecurityIdentifier (WellKnownSidType.BuiltinUsersSid, null);
RawAcl acl = MakeRawAcl(new GenericAce[] {
new CommonAce (AceFlags.None, AceQualifier.AccessDenied, 4, sid, false, null),
new CommonAce (AceFlags.None, AceQualifier.AccessDenied, 8, sid, false, null),
new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 1, sid, false, null),
new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 2, sid, false, null),
new CommonAce (AceFlags.Inherited, AceQualifier.AccessAllowed, 4, sid, false, null),
new CommonAce (AceFlags.Inherited, AceQualifier.AccessAllowed, 4, sid, false, null)
});
Assert.AreEqual (6, acl.Count);
DiscretionaryAcl dacl = new DiscretionaryAcl (false, false, acl);
Assert.IsTrue (dacl.IsCanonical);
Assert.AreEqual (4, dacl.Count);
Assert.AreEqual (AceFlags.None, ((CommonAce)dacl [0]).AceFlags);
Assert.AreEqual (AceFlags.None, ((CommonAce)dacl [1]).AceFlags);
Assert.AreEqual (AceFlags.Inherited, ((CommonAce)dacl [2]).AceFlags);
Assert.AreEqual (AceFlags.Inherited, ((CommonAce)dacl [3]).AceFlags);
Assert.AreEqual (AceQualifier.AccessDenied, ((CommonAce)dacl [0]).AceQualifier);
Assert.AreEqual (AceQualifier.AccessAllowed, ((CommonAce)dacl [1]).AceQualifier);
Assert.AreEqual (AceQualifier.AccessAllowed, ((CommonAce)dacl [2]).AceQualifier);
Assert.AreEqual (AceQualifier.AccessAllowed, ((CommonAce)dacl [3]).AceQualifier);
GenericAce ace7 = dacl[0];
Assert.IsInstanceOfType (typeof (CommonAce), ace7);
dacl.RemoveInheritedAces ();
Assert.AreEqual (2, dacl.Count);
dacl.Purge (sid);
Assert.AreEqual (0, dacl.Count);
}