Creates a new audit rule, specifying the user the rule applies to, the access rights to audit, the inheritance and propagation of the rule, and the outcome that triggers the rule.
- identityReference
- An System.Security.Principal.IdentityReference that identifies the user or group the rule applies to.
- accessMask
- A bitwise combination of System.Security.AccessControl.RegistryRights values specifying the access rights to audit, cast to an integer.
- isInherited
- A Boolean value specifying whether the rule is inherited.
- inheritanceFlags
- A bitwise combination of System.Security.AccessControl.InheritanceFlags values specifying how the rule is inherited by subkeys.
- propagationFlags
- A bitwise combination of System.Security.AccessControl.PropagationFlags values that modify the way the rule is inherited by subkeys. Meaningless if the value of inheritanceFlags is InheritanceFlags.None.
- flags
- A bitwise combination of System.Security.AccessControl.AuditFlags values specifying whether to audit successful access, failed access, or both.
A System.Security.AccessControl.RegistryAuditRule object representing the specified audit rule for the specified user, with the specified flags. The return type of the method is the base class, System.Security.AccessControl.AuditRule, but the return value can be cast safely to the derived class.
The recommended way to create audit rules is to use the constructors of the System.Security.AccessControl.RegistryAuditRule class.
Although you can specify the InheritanceFlags.ObjectInherit flag, there is no point in doing so. For the purposes of audit control, the name/value pairs in a subkey are not separate objects. The audit rights to name/value pairs are controlled by the rights of the subkey. Furthermore, since all subkeys are containers (that is, they can contain other subkeys), they are not affected by the InheritanceFlags.ObjectInherit flag. Finally, specifying the InheritanceFlags.ObjectInherit flag needlessly complicates the maintenance of rules, because it interferes with the normal combination of compatible rules.