Failure audits

  • Hello, I have enabled SQL Server Audit to write to the Application event log. Seems to be working fine but it is only logging success. How do I enable failure logging for things like select/insert/update/delete?

    Thanks for reading.

    Howard

  • There is no logging for insert/update/deletes. You can enable SQL Trace, but you are potentially asking for a ton of data.

    What are you trying to accomplish? Typically there isn't a "failure" of a select/insert/update/delete on a regular basis.

  • SQL Server 2008 Audit allows auditing of a number of things including select/insert/update/delete. It is working properly for capturing these events to the Windows Application or event log but it is only capturing Audit Success. I have a requirement to capture audit failures too such as a select of a table that does not exist or where the user does not have access. I think it may be an option in the audit policy but not sure how to set it.

    Here is an example entry:

    Date1/9/2012 6:51:27 PM

    LogAudit Collection (Audit-20120109-115026)

    Event Time 18:51:27.9823720

    Server Instance Name<name here>

    Action IDSELECT

    Class TypeTABLE

    Sequence Number1

    SucceededTrue

    Permission Bit Mask0x0000000000000001

    Column PermissionTrue

    Session ID61

    Server Principal ID259

    Database Principal ID1

    Target Server Principal ID0

    Target Database Principal ID0

    Object ID530100929

    Session Server Principal Name<user name>

    Server Principal Name<user name>

    Server Principal SID<id>

    Database Principal Namedbo

    Target Server Principal Name

    Target Server Principal SIDNULL

    Target Database Principal Name

    Database NameDBA_Maintenance

    Schema Namedbo

    Object Nametest

    Statementselect * FROM [DBA_Maintenance].[dbo].[test]

    Additional Information

    File NameD:\dba\Audit-20120109-115026_xxx.sqlaudit

    File Offset6144

    User Defined Event ID0

    User Defined Information

    Message

  • Sorry, was thinking of something else when I posted, not SQL Server Audit, as in the feature.

    In terms of auditing the SELECT/INSERT/UPDATE/DELETE, a database audit specification will do this, but it audits the execution of the statement. A "failure" isn't a failure of the statement. It's another error. If someone executes a SELECT against a non-existent table, that's not a SELECT failure, that could be seen as a syntax error, or an object reference error, but the SELECT hasn't failed. An insert that has a duplicate key value is an FK error, not an insert error.

    If I understand it correctly from limited use, you will get all executions of the statement, which is defined per object, and you'd have to sort through them, maybe filtering on some keyword in the logs. I'm not sure you can limit it to just one particular type of execution.

    Understanding Audit - http://msdn.microsoft.com/en-us/library/cc280386%28v=SQL.100%29.aspx

    Create DB spec - http://msdn.microsoft.com/en-us/library/cc280404%28v=SQL.100%29.aspx

  • Thanks for helping me to understand.

    I see now that if I give a user read only permission and they attempt to update a table, it will log a failure. This is very good.

    The confusion was when I was expecting a user who runs a bad query such as a select of a table that does not exist that it would record that as well. But technicly as you say, it is a successful select but of non existant data. These type of things are not logged by SQL Server Audit but would help us to detect anyone who was fishing for data.

    Thanks again.

  • You could always go another route. That is to put a sniffer in front of the SQL Server that logs all incoming traffic. You do not need to log the Output. (It will be way too much data)

    -Roy

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply