AddAuditAccessObjectAce

[This is preliminary documentation and subject to change.]

The AddAuditAccessObjectAce function adds a system-audit ACE to the end of a SACL. The new ACE can audit access to an object, or to a property set or property on an object. You can also use AddAuditAccessObjectAce to add an ACE that only a specified type of child object can inherit.

BOOL AddAuditAccessObjectAce(
  PACL pAcl,             // pointer to an ACL
  DWORD dwAceRevision,   // ACL revision level
  DWORD AceFlags,        // ACE inheritance flags
  DWORD AccessMask,      // access mask for the new ACE
  GUID *ObjectTypeGuid,  // type of object protected by the ACE
  GUID *InheritedObjectTypeGuid,  
                         // type of object that can inherit the ACE
  PSID pSid,             // SID of the trustee for the new ACE
  BOOL bAuditSuccess,    // audit successful access attempts
  BOOL bAuditFailure     // audit unsuccessful access attempts
);
 

Parameters

pAcl
Pointer to a SACL. The AddAuditAccessObjectAce function adds a system-audit ACE to the end of this SACL. The ACE is in the form of a SYSTEM_AUDIT_OBJECT_ACE structure.
dwAceRevision
Specifies the revision level of the SACL being modified. This value must be ACL_REVISION_DS. If the SACL's revision level is lower than ACL_REVISION_DS, the function changes it to ACL_REVISION_DS.
AceFlags
A set of bit flags that control ACE inheritance and the type of access attempts to audit. The function sets these flags in the AceFlags member of the ACE_HEADER structure of the new ACE. This parameter can be a combination of the following values.
Value Meaning
CONTAINER_INHERIT_ACE
The ACE is inherited by container objects.
FAILED_ACCESS_ACE_FLAG
If you set this flag or specify TRUE for the bAuditFailure parameter, failed attempts to use the specified access rights cause the system to generate an audit record in the security event log.
INHERIT_ONLY_ACE
The ACE does not apply to the object to which the ACL is assigned, but it can be inherited by child objects.
INHERITED_ACE
Indicates an inherited ACE. This flag allows operations that change the security on a tree of objects to modify inherited ACEs, while not changing ACEs that were directly applied to the object.
NO_PROPAGATE_INHERIT_ACE
The OBJECT_INHERIT_ACE and CONTAINER_INHERIT_ACE bits are not propagated to an inherited ACE.
OBJECT_INHERIT_ACE
The ACE is inherited by noncontainer objects.
SUCCESSFUL_ACCESS_ACE_FLAG
If you set this flag or specify TRUE for the bAuditSuccess parameter, successful uses of the specified access rights cause the system to generate an audit record in the security event log.

AccessMask
An ACCESS_MASK that specifies the access rights that the new ACE audits for the specified SID. This mask must use the Windows NT access mask format, not the provider-independent access-mask format.
ObjectTypeGuid
Pointer to a GUID structure that identifies the type of object, property set, or property protected by the new ACE. If this parameter is NULL, the new ACE protects the object to which the ACL is assigned.
InheritedObjectTypeGuid
Pointer to a GUID structure that identifies the type of object that can inherit the new ACE. If this parameter is non-NULL, only the specified object type can inherit the ACE. If NULL, any type of child object can inherit the ACE. In either case, inheritance is also controlled by the value of the AceFlags parameter, as well as by any protection against inheritance placed on the child objects.
pSid
Pointer to a SID structure that identifies the user, group, or logon session for which the new ACE audits access.
bAuditSuccess
Specifies whether successful uses of the specified access rights cause the system to generate an audit record in the security event log. If this flag is TRUE or if the AceFlags parameter specifies the SUCCESSFUL_ACCESS_ACE_FLAG flag, the system records successful access attempts; otherwise, it does not.
bAuditFailure
Specifies whether failed attempts to use the specified access rights cause the system to generate an audit record in the security event log. If this flag is TRUE or if the AceFlags parameter specifies the FAILED_ACCESS_ACE_FLAG flag, the system records failed access attempts; otherwise, it does not.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError. If the AceFlags parameter specifies invalid flags, GetLastError returns ERROR_INVALID_FLAGS.

Remarks

If both ObjectTypeGuid and InheritedObjectTypeGuid are NULL, use the AddAuditAccessAceEx function rather than AddAuditAccessObjectAce. This is suggested because a SYSTEM_AUDIT_ACE is smaller and more efficient than an SYSTEM_AUDIT_OBJECT_ACE.

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use advapi32.lib.

See Also

Low-Level Access-Control Overview, Low-Level Access Control Functions, ACE_HEADER, ACL, AddAccessAllowedObjectAce, AddAccessDeniedObjectAce, AddAuditAccessAceEx, SYSTEM_AUDIT_ACE, SYSTEM_AUDIT_OBJECT_ACE