public void SetDiscretionaryAclProtection(bool isProtected,
                                                  bool preserveInheritance)
        {
            DiscretionaryAcl.IsAefa = false;

            if (!isProtected)
            {
                flags &= ~ControlFlags.DiscretionaryAclProtected;
                return;
            }

            flags |= ControlFlags.DiscretionaryAclProtected;
            if (!preserveInheritance)
            {
                DiscretionaryAcl.RemoveInheritedAces();
            }
        }
        public void SetDiscretionaryAclProtection(bool isProtected, bool preserveInheritance)
        {
            if (!isProtected)
            {
                RemoveControlFlags(ControlFlags.DiscretionaryAclProtected);
            }
            else
            {
                if (!preserveInheritance && DiscretionaryAcl != null)
                {
                    DiscretionaryAcl.RemoveInheritedAces();
                }

                AddControlFlags(ControlFlags.DiscretionaryAclProtected);
            }
            if (DiscretionaryAcl != null && DiscretionaryAcl.EveryOneFullAccessForNullDacl)
            {
                DiscretionaryAcl.EveryOneFullAccessForNullDacl = false;
            }
        }
Esempio n. 3
0
		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);
		}