How to Grant Permission to View Database Audit Logs to Non-Sysadmin Login – SQL Server

auditpermissionssql server

I have a non-sysadmin user which must be provided with an ability to view "server audit logs"

Tried to grant below permissions to this login / user:

grant ALTER ANY server AUDIT  to [login]
grant ALTER ANY database AUDIT  to [user]

But if he runs below, he is still getting error message:

select top 100 * from fn_get_audit_file(Path:\\...)

Msg 297, Level 16, State 1, Line 44
The user does not have permission to perform this action.

So, is there an ability to grant non-admin user permission to view audit logs ?

Thanks!

Best Answer

Reference:

Microsoft recommends viewing the audit log by using the Log File Viewer. However, if you are creating an automated monitoring system, the information in the audit file can be read directly by using the sys.fn_get_audit_file (Transact-SQL) function. Reading the file directly returns data in a slightly different (unprocessed) format. See sys.fn_get_audit_file for more information.

In order to use sys.fn_get_audit_file users requires the CONTROL SERVER permission.

You can deny privilege on a principle who has been assigned CONTROL SERVER permission which is not possible in case of SYSADMIN.

More about this:

Security Questions: Difference between sysadmin and CONTROL SERVER Permission by Jason Strate.