SetAudit() public method

public SetAudit ( System sid, System rule ) : void
sid System
rule System
return void
Ejemplo n.º 1
0
		public void SetAudit ()
		{
			SecurityIdentifier adminSid = new SecurityIdentifier ("BA"); // S-1-5-32-544
			SecurityIdentifier userSid = new SecurityIdentifier ("BU"); // S-1-5-32-545

			SystemAcl sacl = new SystemAcl (true, false, 0);
			sacl.SetAudit (AuditFlags.Success, adminSid, 1, InheritanceFlags.ObjectInherit, PropagationFlags.None);
			sacl.SetAudit (AuditFlags.Success, userSid, 2, InheritanceFlags.None, PropagationFlags.None);
			Assert.AreEqual (2, sacl.Count);

			CommonAce ace = (CommonAce)sacl [0];
			Assert.AreEqual (adminSid, ace.SecurityIdentifier);
			Assert.AreEqual (1, ace.AccessMask);

			sacl.SetAudit (AuditFlags.Success, adminSid, 4, InheritanceFlags.ObjectInherit, PropagationFlags.None);
			Assert.AreNotEqual (4, ace.AccessMask);
			ace = (CommonAce)sacl [0];
			Assert.AreEqual (4, ace.AccessMask);

			sacl.SetAudit (AuditFlags.Failure, adminSid, 4, InheritanceFlags.ObjectInherit, PropagationFlags.None);
			Assert.AreEqual (2, sacl.Count);
			ace = (CommonAce)sacl [0];
			Assert.AreEqual (AuditFlags.Failure, ace.AuditFlags);
			Assert.AreEqual (adminSid, ace.SecurityIdentifier);
			ace = (CommonAce)sacl [1];
			Assert.AreEqual (AuditFlags.Success, ace.AuditFlags);
			Assert.AreEqual (userSid, ace.SecurityIdentifier);
		}