LINKS
General
Apex SQL Audit
Apex SQL Clean
Apex SQL Code
Apex SQL Data Diff
Apex SQL Debug
Apex SQL Diff
Apex SQL Diff API
Apex SQL Doc
Apex SQL Edit
Apex SQL Enforce
Apex SQL Log
Apex SQL Log API
Apex SQL Recover
Apex SQL Refactor
Apex SQL Report
Apex SQL Script
Apex SQL Source Ctl
Apex SQL SSIS Compare
Knowledgebase Home
Apex SQL Audit
Apex SQL Clean
Apex SQL Code
Apex SQL Data Diff
Apex SQL Debug
Apex SQL Diff
Apex SQL Diff API
Apex SQL Doc
Apex SQL Edit
Apex SQL Enforce
Apex SQL Log
Apex SQL Log API
Apex SQL Recover
Apex SQL Refactor
Apex SQL Report
Apex SQL Script
Apex SQL Source Ctl
Apex SQL SSIS Compare
Knowledgebase Home
SITE FEED
Support Forum
FAQs
Troubleshooting
Online Documentation
|
ApexSQL Knowledgebase Tips and How-to Articles for Apex SQL Tools How to audit only some users in ApexSQLAudit? DESCRIPTION This article discusses how to audit only chosen users with ApexSQL's Audit SOLUTION This is possible through changing the Trigger Template. To access the Trigger Template, click on the Template Editor button found on the Outlook Bar Auditing section: ![]() This will start Template Editor: ![]() Next, you should find the part where trigger for INSERT command is created: '================================================== 'INSERT INSERT INSERT INSERT '================================================== caption = "Create Insert Trigger " & "[" & objTable.Owner & "].[" & StartTriggerNameInsert & objTable.Name & "]" & _ ">" for Table " & TableFullName%} IF OBJECT_ID('{%Audit.Print replace("[" & objTable.Owner & "].[" & StartTriggerNameInsert & objTable.Name & "]", "'", "''") %}','TR') IS NOT NULL BEGIN DROP TRIGGER {%Audit.Print "[" & objTable.Owner & "].[" & StartTriggerNameInsert & objTable.Name & "]" %} PRINT '{% Audit.Print "Trigger Dropped: " & StartTriggerNameInsert & Replace(objTable.Name,"'","''")%}' END GO -- {%Audit.Print caption%} Print '{%Audit.Print Replace(caption, "'", "''")%}' go CREATE TRIGGER {%Audit.Print "[" & objTable.Owner & "].[" & StartTriggerNameInsert & objTable.Name & "]" %} ON {%Audit.Print TableFullName%} FOR INSERT NOT FOR REPLICATION As -- " -- ------------------------------------------------------------------------------------------- -- Legal: {%Audit.Print Audit.Legal%} -- Description: INSERT TRIGGER for Table: {%Audit.Print TableFullName%} -- Author: {%Audit.Print Audit.Author%} -- Date: {%Audit.Print Now%} -- ------------------------------------------------------------------------------------------- BEGIN there you should add following: IF (SUSER_SNAME() <> N'ComputerName\UserName1') AND (SUSER_NAME() <> N'ComputerName\UserName2') RETURN Where ComputerName\UserName1 and ComputerName\UserName2 are the user names you want to include in auditing in case they use Windows Authentication on connecting to your server or UserNam1 and UserName2 in case they use SQL Authentication. These steps you need to repeat for UPDATE (found below this) '================================================== ' UPDATE UPDATE UPDATE UPDATE UPDATE '================================================== and DELETE trigger template. '================================================== ' DELETE DELETE DELETE DELETE '================================================== with the same command: IF (SUSER_SNAME() <> N'ComputerName\UserName1') AND (SUSER_NAME() <> N'ComputerName\UserName2') RETURN Then you need to recreate triggers on your tables. First, check tables and columns you want to audit, and then create triggers by clicking on the Create Triggers button: ![]() Script will be built. You just need to execute it: ![]() This will recreate all triggers, and now only users with given names will be audited. SEE ALSO How to audit user names in ASP.Net application How to update ApexSQL Audit without losing custom changes in the architecture Schedule Audit Report generation How to Delete Old Data in Audit tables AUTHOR Milic Vuletic LAST REVIEW DATE 19 November 2009 Labels: Apex SQL Audit |
© 2010 Apex SQL Tools All Rights Reserved | 1.919.968.8444 | Contact Us | Terms of Use | Privacy Policy




