AuditQueryPerUserPolicy function (ntsecapi.h)

The AuditQueryPerUserPolicy function retrieves per-user audit policy in one or more audit-policy subcategories for the specified principal.


BOOLEAN AuditQueryPerUserPolicy(
  [in]  const PSID                pSid,
  [in]  const GUID                *pSubCategoryGuids,
  [in]  ULONG                     dwPolicyCount,


[in] pSid

A pointer to the SID structure associated with the principal for which to query audit policy. Per-user policy for group SIDs is not currently supported.

[in] pSubCategoryGuids

A pointer to an array of GUID values that specify the subcategories for which to query audit policy. For a list of defined audit-policy subcategories, see Auditing Constants.

[in] dwPolicyCount

The number of elements in each of the pSubCategoryGuids and ppAuditPolicy arrays.

[out] ppAuditPolicy

A pointer to a single buffer that contains both an array of pointers to AUDIT_POLICY_INFORMATION structures and the structures themselves. The AUDIT_POLICY_INFORMATION structures specify the per-user audit policy for the subcategories specified by the pSubCategoryGuids array.

When you have finished using this buffer, free it by calling the AuditFree function.

Return value

If the function succeeds, it returns TRUE.

If the function fails, it returns FALSE. To get extended error information, call GetLastError. GetLastError may return one of the following error codes defined in WinError.h.

Return code/value Description
No per-user audit policy exists for the principal specified by the pSid parameter.
The caller does not have the privilege or access rights necessary to call this function.
One or more parameters are invalid.


To successfully call this function, the caller must have SeSecurityPrivilege or have AUDIT_QUERY_USER_POLICY access on the Audit security object.


Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header ntsecapi.h
Library Advapi32.lib
DLL Advapi32.dll