Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Failure audits Expand / Collapse
Author
Message
Posted Monday, January 9, 2012 11:17 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 2:56 PM
Points: 303, Visits: 942
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
Post #1232685
Posted Monday, January 9, 2012 11:43 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 8:39 AM
Points: 31,176, Visits: 15,615
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.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1232702
Posted Monday, January 9, 2012 11:58 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 2:56 PM
Points: 303, Visits: 942
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:

Date 1/9/2012 6:51:27 PM
Log Audit Collection (Audit-20120109-115026)

Event Time 18:51:27.9823720
Server Instance Name <name here>
Action ID SELECT
Class Type TABLE
Sequence Number 1
Succeeded True
Permission Bit Mask 0x0000000000000001
Column Permission True
Session ID 61
Server Principal ID 259
Database Principal ID 1
Target Server Principal ID 0
Target Database Principal ID 0
Object ID 530100929
Session Server Principal Name <user name>
Server Principal Name <user name>
Server Principal SID <id>
Database Principal Name dbo
Target Server Principal Name
Target Server Principal SID NULL
Target Database Principal Name
Database Name DBA_Maintenance
Schema Name dbo
Object Name test
Statement select * FROM [DBA_Maintenance].[dbo].[test]
Additional Information
File Name D:\dba\Audit-20120109-115026_xxx.sqlaudit
File Offset 6144
User Defined Event ID 0
User Defined Information

Message

Post #1232714
Posted Monday, January 9, 2012 12:29 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 8:39 AM
Points: 31,176, Visits: 15,615
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







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1232737
Posted Wednesday, January 11, 2012 12:36 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 2:56 PM
Points: 303, Visits: 942
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.
Post #1234298
Posted Thursday, January 12, 2012 10:47 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 7:31 AM
Points: 2,361, Visits: 6,749
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
Post #1235100
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse