liveBook · Manning

Windows Security log

As explained in 100 SQL Server Mistakes and How to Avoid Them

The Windows security log is an operating-system event log that records security-related events and is protected by Windows access controls.

Mistake: leaving administrative activity unaudited. SQL Server Audit can write privileged actions to the Windows security log, helping establish accountability and preventing SQL Server administrators from tampering with the audit record. section 14.5

Make the logging path usable before creating the SQL Server audit:

  • Enable application-generated audit events through auditpol. section 14.5
  • Grant the SQL Server service account the Generate Security Audits user right. section 14.5
  • Configure audit policy to record both successful and failed object-access events, then restart the server. section 14.5
Listing 14.6 Creating an audit object
USE master ;
GO
 
CREATE SERVER AUDIT AdminActivityAudit
TO SECURITY_LOG WITH (
     ON_FAILURE = CONTINUE
) ;

Creates a SQL Server audit targeting SECURITY_LOG and defines behavior when writing fails. section 14.5

Listing 14.7 Creating an audit specification
CREATE SERVER AUDIT SPECIFICATION AdminActivitySpecification
FOR SERVER AUDIT AdminActivityAudit
   ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP),
   ADD (AUDIT_CHANGE_GROUP),
   ADD (DBCC_GROUP),
   ADD (SERVER_OBJECT_PERMISSION_CHANGE_GROUP),
   ADD (SERVER_PERMISSION_CHANGE_GROUP),
   ADD (SERVER_PRINCIPAL_IMPERSONATION_GROUP),
   ADD (SERVER_OBJECT_CHANGE_GROUP),
   ADD (SERVER_PRINCIPAL_CHANGE_GROUP),
   ADD (SERVER_OPERATION_GROUP),
   ADD (SERVER_STATE_CHANGE_GROUP),
   ADD (SERVER_OBJECT_OWNERSHIP_CHANGE_GROUP) ;

Adds administrative action groups for role changes, audit changes, DBCC, permissions, impersonation, object changes, and server operations. section 14.5

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains prerequisites, failure handling, and audit action groups, but does not detail event review or alerting.
Examples
Uses AdminActivityAudit and AdminActivitySpecification examples covering audit changes, DBCC, permissions, impersonation, and server operations.
What it assumes
Requires Windows audit-policy changes, service-account rights, and a server restart before SQL Server can write events.
What you can do after
Operate/configure SQL Server Audit to write administrative events to the Windows security log and choose failure behavior.
How it connects
Connects Windows security log with SQL Server Audit, nonrepudiation, audit policy, and privileged-account accountability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.