AddAudit() public method

public AddAudit ( System sid, System rule ) : void
sid System
rule System
return void
Beispiel #1
0
		public void AddAuditObjectAceAndCommonAce ()
		{
			SecurityIdentifier sid = new SecurityIdentifier ("BA");
			SystemAcl sacl = new SystemAcl (false, true, 0);

			sacl.AddAudit (AuditFlags.Success, sid, 1, InheritanceFlags.None, PropagationFlags.None,
			               ObjectAceFlags.ObjectAceTypePresent, Guid.NewGuid (), Guid.Empty);
			sacl.AddAudit (AuditFlags.Success, sid, 1, InheritanceFlags.None, PropagationFlags.None,
				       ObjectAceFlags.None, Guid.Empty, Guid.Empty);
			Assert.AreEqual (2, sacl.Count);

			CommonAce cace = (CommonAce)sacl [0];
			Assert.AreEqual (1, cace.AccessMask);
			Assert.AreEqual ("S-1-5-32-544", cace.SecurityIdentifier.Value);
			Assert.IsFalse (cace.IsCallback);
			Assert.IsFalse (cace.IsInherited);

			ObjectAce oace = (ObjectAce)sacl [1];
			Assert.AreEqual (1, oace.AccessMask);
			Assert.AreEqual ("S-1-5-32-544", oace.SecurityIdentifier.Value);
			Assert.IsFalse (oace.IsCallback);
			Assert.IsFalse (oace.IsInherited);

			sacl.AddAudit (AuditFlags.Success, sid, 2, InheritanceFlags.None, PropagationFlags.None,
				       ObjectAceFlags.None, Guid.Empty, Guid.Empty);
			Assert.AreEqual (2, sacl.Count);

			CommonAce cace2 = (CommonAce)sacl [0];
			Assert.AreEqual (3, cace2.AccessMask);
		}
Beispiel #2
0
		public void AddAuditMergesFlags ()
		{
			SecurityIdentifier sid = new SecurityIdentifier ("BA");
			SystemAcl sacl = new SystemAcl (false, false, 0);

			sacl.AddAudit (AuditFlags.Success, sid, 1, InheritanceFlags.None, PropagationFlags.None);
			sacl.AddAudit (AuditFlags.Failure, sid, 1, InheritanceFlags.None, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);

			CommonAce ace = (CommonAce)sacl [0];
			Assert.AreEqual (AuditFlags.Success|AuditFlags.Failure, ace.AuditFlags);
		}
Beispiel #3
0
		public void AddAuditCommonAce ()
		{
			SecurityIdentifier sid = new SecurityIdentifier ("BA");
			SystemAcl sacl = new SystemAcl (false, false, 0);

			sacl.AddAudit (AuditFlags.Success, sid, 1, InheritanceFlags.None, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);

			CommonAce ace = (CommonAce)sacl [0];
			Assert.AreEqual (AuditFlags.Success, ace.AuditFlags);
			Assert.AreEqual (1, ace.AccessMask);
			Assert.AreEqual ("S-1-5-32-544", ace.SecurityIdentifier.Value);
			Assert.IsFalse (ace.IsInherited);
		}
Beispiel #4
0
		public void AddAuditCommonAceUsingDSOverload ()
		{
			SecurityIdentifier sid = new SecurityIdentifier ("BA");
			SystemAcl sacl = new SystemAcl (false, true, 0);

			sacl.AddAudit (AuditFlags.Failure, sid, 1, InheritanceFlags.None, PropagationFlags.None,
			               ObjectAceFlags.None, Guid.NewGuid (), Guid.NewGuid ());
			Assert.AreEqual (1, sacl.Count);

			CommonAce ace = (CommonAce)sacl [0];
			Assert.AreEqual (AuditFlags.Failure, ace.AuditFlags);
			Assert.AreEqual (1, ace.AccessMask);
			Assert.AreEqual ("S-1-5-32-544", ace.SecurityIdentifier.Value);
			Assert.IsFalse (ace.IsInherited);
		}
Beispiel #5
0
		void RemoveSpecificBegin (SecurityIdentifier sid, SystemAcl sacl, InheritanceFlags inheritanceFlags)
		{
			SecurityIdentifier otherSid = new SecurityIdentifier ("BU");

			sacl.AddAudit (AuditFlags.Success, sid, 3, inheritanceFlags, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);
			sacl.RemoveAuditSpecific (AuditFlags.Failure, sid, 1, inheritanceFlags, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);
			sacl.RemoveAuditSpecific (AuditFlags.Success, otherSid, 1, inheritanceFlags, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);
			sacl.RemoveAuditSpecific (AuditFlags.Success, sid, 1, inheritanceFlags, PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);
			Assert.AreEqual (3, ((CommonAce)sacl [0]).AccessMask);
			sacl.RemoveAuditSpecific (AuditFlags.Success, sid, 3,
			                          inheritanceFlags ^ InheritanceFlags.ContainerInherit,
			                          PropagationFlags.None);
			Assert.AreEqual (1, sacl.Count);
		}