<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BI Monkey &#187; Audit</title>
	<atom:link href="http://www.bimonkey.com/tag/audit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bimonkey.com</link>
	<description>James Beresford on Microsoft BI and Consulting in Sydney, Australia</description>
	<lastBuildDate>Mon, 06 Sep 2010 00:59:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server 2008 Auditing</title>
		<link>http://www.bimonkey.com/2009/12/sql-server-2008-auditing/</link>
		<comments>http://www.bimonkey.com/2009/12/sql-server-2008-auditing/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 11:52:08 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Audit]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=694</guid>
		<description><![CDATA[I recently got presented with this challenge: How do you monitor people disabling your SQL Agent Jobs? Not prevent, warn or notify&#8230; just be able to monitor and find out who did what, when?
Enter SQL Server Auditing, introduced in 2008.
What is SQL 2008 Auditing?
Well, you could read the official documentation on MSDN, but it&#8217;s a little [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got presented with this challenge: How do you monitor people disabling your SQL Agent Jobs? Not prevent, warn or notify&#8230; just be able to monitor and find out who did what, when?</p>
<p>Enter <strong>SQL Server Auditing</strong>, introduced in 2008.</p>
<h2>What is SQL 2008 Auditing?</h2>
<p>Well, you could <a title="Understanding SQL Server Audit" href="http://msdn.microsoft.com/en-us/library/cc280386.aspx">read the official documentation on MSDN</a>, but it&#8217;s a little overwhelming, so here&#8217;s the view from 500 ft. SQL Server Audit provides a secure means of tracking access and changes made to the database schema or its data. What this means is you can trace who tried to access what and when. If any command was issued to change the data, you can track this as well. You <span style="text-decoration: underline;">cannot</span> track the changes made to the data. So for example if someone made an insert into a table, you could track that someone made an insert, who did it, when that insert was made and what the SQL of the insert statement looked like &#8211; except for what data was inserted. That task falls to Change Data capture (CDC) which isn&#8217;t directly tied to Auditing (currently).</p>
<h2>How do I implement Auditing?</h2>
<p>A SQL Server Audit is made up of two components, the first of which is the SQL Server Audit. This is a server level object (created in the <strong>master</strong> database) that defines where logs will be written. Logs can be written to either a file, the Application Log or Security Log. These must be created before you create any actual Audits.</p>
<p>The second component is either a Server Audit or Database Audit. Server Audits again exist at the server level, and track activities that occur at the server level, such as login attempts or permission changes. Database Audits exist within an individual database and track activities at a database level such as schema changes or data operations.</p>
<p>You can have multiple SQL Server Audits defining multiple log target locations. Multiple Server and Database audits can be created to use a given SQL Server Audit. This probably makes more sense when explained in pictures:</p>
<div class="wp-caption alignnone" style="width: 571px"><a href="http://www.bimonkey.com/uploads/sql/SQLAudit.jpg"><img class=" " title="SQL 2008 Auditing Hierarchy" src="http://www.bimonkey.com/uploads/sql/SQLAudit.jpg" alt="SQL 2008 Auditing Hierarchy" width="561" height="398" /></a><p class="wp-caption-text">Fig 1: SQL 2008 Auditing Hierarchy</p></div>
<p> </p>
<h2>So how do I audit my SQL Agent Jobs?</h2>
<p>Setting up Audits can either be done through SQL Server Management Studio (SSMS) or through SQL scripts. As usual any action carried out through the Wizard, so I will do the wizard first, then show the generated scripts.</p>
<p>Step 1 is setting up the SQL Server Audit. To create this in SSMS, under the Security Node of the Server is a folder called &#8220;Audits&#8221;. To create a new Audit, simply right click on the folder and choose &#8220;New Audit..&#8221;, as set out below:</p>
<div class="wp-caption alignnone" style="width: 382px"><img class="   " title="Creating a SQL Server Audit" src="http://www.bimonkey.com/uploads/sql/sqlserveraudit_ssms.jpg" alt="Creating a SQL Server Audit" width="372" height="409" /><p class="wp-caption-text">Fig 2: Creating a SQL Server Audit</p></div>
<p>Then in the Wizard just enter the Audit name and in the dropdown select &#8220;Application Log&#8221;, as shown below. The alternatives are to the Security Log or to a File, but I won&#8217;t be covering those in this simple example. Click on OK and you&#8217;re done.</p>
<div class="wp-caption alignnone" style="width: 691px"><img class="   " title="Creating a SQL Server Audit" src="http://www.bimonkey.com/uploads/sql/sqlserveraudit_ssms_new_audit.jpg" alt="Creating a SQL Server Audit" width="681" height="250" /><p class="wp-caption-text">Fig 3: Creating a SQL Server Audit</p></div>
<p>The equivalent SQL script is below:</p>
<blockquote><p><span style="color: #0000ff;">USE </span>[master]</p>
<p><span style="color: #0000ff;">GO</span></p>
<p><span style="color: #0000ff;">CREATE SERVER</span> AUDIT [My Sample Audit]<br />
<span style="color: #0000ff;">TO</span> APPLICATION_LOG<br />
<span style="color: #0000ff;">WITH</span><br />
( QUEUE_DELAY = 1000<br />
 ,ON_FAILURE = <span style="color: #0000ff;">CONTINUE</span><br />
)</p>
<p><span style="color: #0000ff;">GO</span></p></blockquote>
<p>Now you have somewhere to write your log. Note that by default SQL Server Audits are <strong>disabled</strong> when they are created, which means nothing will be written to your log until until it is enabled. This can be done just by right clicking on it in SSMS and choosing &#8220;Enable&#8221;.</p>
<p>The next bit is to set up the Database Audit on the SQL Agent Jobs table, which is in the system table [msdb].[dbo].[sysjobs]. Under the msdb database, open up the &#8220;Security&#8221; folder and within there is the &#8220;Database Audit Specifications&#8221; folder. Right click here and choose &#8220;New Database Audit Specification&#8230;&#8221; as shown below.</p>
<div class="wp-caption alignnone" style="width: 572px"><img class="    " title="Creating a Database Audit Specification" src="http://www.bimonkey.com/uploads/sql/databaseaudit_ssms.jpg" alt="Creating a Database Audit Specification" width="562" height="647" /><p class="wp-caption-text">Fig 4: Creating a Database Audit Specification</p></div>
<p>This will open the Create Database Audit Specification dialog. Because we are operating on msdb, unless you are logged in as <strong>sa</strong>, you probably won&#8217;t be able to create objects and the process will fail. So ensure the user you are logged in as has appropriate permissions on msdb. Because I&#8217;m playing on a Dev environment, I just allowed my own user access to msdb and gave them db_owner rights &#8211; this probably won&#8217;t fly in a production environment, of course!</p>
<p>The dialog is shown below. First task is to choose which SQL Server Audit to write to &#8211; so we use the one we created above called &#8221;My Sample Audit&#8221;. You choose the Audit Action Type &#8211; i.e. what you want to log. In our case we want to see when changes are made to our jobs in SQL Agent, so we choose the &#8220;UPDATE&#8221; Action Type. Next we have the Object Class, which for this case is a Database Object, so &#8220;Object&#8221; is selected, and then the Object Name. Finally the Principal defines who is Audited &#8211; in the example I have selected &#8220;public&#8221; because every user is in the public role, so I will capture any users UPDATE commands issued on my selected table.</p>
<div class="wp-caption alignnone" style="width: 1052px"><img class="   " title="Creating a Database Audit Specification" src="http://www.bimonkey.com/uploads/sql/sqlserveraudit_ssms_new_dbaudit.jpg" alt="Creating a Database Audit Specification" width="1042" height="288" /><p class="wp-caption-text">Fig 5: Creating a Database Audit Specification</p></div>
<p>Now here we hit a minor hiccup &#8211; you will note in the example above I have selected the object sysdtslog90 &#8211; it&#8217;s the only non-system view in the database, and the only one I can get to come up in the browser. The solution here is just to hit the &#8220;Script&#8221; button, and modify the generated code to point at the right table, as shown below:</p>
<blockquote><p><span style="color: #0000ff;">USE</span>[msdb]</p>
<p><span style="color: #0000ff;">GO</span></p>
<p><span style="color: #0000ff;">CREATE DATABASE</span> AUDIT SPECIFICATION [SQL Agent Audit]<br />
<span style="color: #0000ff;">FOR SERVER</span> AUDIT [My Sample Audit]<br />
<span style="color: #0000ff;">ADD</span> (<span style="color: #0000ff;">UPDATE ON OBJECT</span>::<strong>[dbo].[sysjobs]</strong> <span style="color: #0000ff;">BY</span> [public])</p>
<p>GO</p></blockquote>
<p>This code runs just fine, and as you will see has the desired effect. As with SQL Server Audits, Database Audit Specifications are created in a disabled state. As before, just right click to enable and the Auditing will begin.</p>
<p>Finally to test, just change the Enabled state of any SQL Agent job on your server, then check the Application Log, where you will find an Event detailing who just changed its status!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/12/sql-server-2008-auditing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Audit Transformation</title>
		<link>http://www.bimonkey.com/2009/05/the-audit-transformation/</link>
		<comments>http://www.bimonkey.com/2009/05/the-audit-transformation/#comments</comments>
		<pubDate>Tue, 19 May 2009 09:43:45 +0000</pubDate>
		<dc:creator>BI Monkey</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Audit]]></category>

		<guid isPermaLink="false">http://www.bimonkey.com/?p=185</guid>
		<description><![CDATA[In this post i’m going to cover the Audit Transformation. The sample package can be found here for 2008 and here for 2005, read guidelines on use here.
What is the Audit Transformation?
The Audit Transformation is a simple component that simply adds the values of certain System Variables as new columns (that you name) to the [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">In this post i’m going to cover the Audit Transformation. The sample package can be found <a title="SQL 2008 Audit Transformation Sample Package (Right Click, Save As)" href="http://www.bimonkey.com/uploads/componentreview/Audit Transformation Basics 2008.dtsx">here for 2008</a> and <a title="SQL 2005 Audit Transformation Sample Package (Right Click, Save As)" href="http://www.bimonkey.com/uploads/componentreview/Audit Transformation Basics 2005.dtsx">here for 2005</a>, read guidelines on use <a title="Guidelines on using BI Monkey SSIS Samples" href="http://www.bimonkey.com/support/using-ssis-samples-from-this-site/">here</a>.</div>
<div class="wp-caption alignnone" style="width: 279px"><img style="margin-top: 8px; margin-bottom: 8px;" title="SSIS Audit Transformation" src="http://www.bimonkey.com/uploads/componentreview/audittransformation1.jpg" alt="SSIS Audit Transformation" width="269" height="84" /><p class="wp-caption-text">Fig 1: The Audit Transformation</p></div>
<h2>What is the Audit Transformation?</h2>
<p>The Audit Transformation is a simple component that simply adds the values of certain System Variables as new columns (that you name) to the data flow. It allows for a single System Variable to be added as many times as you like. An example is below:</p>
<div class="wp-caption alignnone" style="width: 494px"><img title="Column Selection in the SSIS Audit Transformation" src="http://www.bimonkey.com/uploads/componentreview/audittransformation2.jpg" alt="Text 2" width="484" height="192" /><p class="wp-caption-text">Fig 2: Column selection</p></div>
<p>These are the variables that are available:</p>
<ul>
<li><strong>ExecutionInstanceGUID </strong>- The GUID that identifies the execution instance of the package.</li>
<li><strong>PackageID </strong>- The unique identifier of the package.</li>
<li><strong>PackageName </strong>- The package name.</li>
<li><strong>VersionID </strong>- The version of the package.</li>
<li><strong>ExecutionStartTime </strong>- The time the package started to run.</li>
<li><strong>MachineName </strong>- The computer name.</li>
<li><strong>UserName </strong>- The login name of the person who started the package.</li>
<li><strong>TaskName </strong>- The name of the Data Flow task with which the Audit transformation is associated.</li>
<li><strong>TaskId </strong>- The unique identifier of the Data Flow task.</li>
</ul>
<p>The sample package demonstrates some of these columns in the Data Flow &#8220;1 &gt; Audit Transformation&#8221;</p>
<h2>When would you use the Audit Transformation?</h2>
<p>The most likely scenario for using this component is in creating log entries or adding metadata to error traps. It does seem  a little redundant though as adding a new column with the value of a System Variable can just as easily be done within a Derived Column Transformation, which offers greater flexibility. So the short answer is, I probably wouldn&#8217;t use this transformation. In the sample package I have a demo of using the Derived Column Transformation to achieve the same goals as the Audit Transformation, in the Data Flow &#8220;2 &gt; Derived Column&#8221;</p>
<p>MSDN documentation for this component can be found <a title="SQL 2008 MSDN Documentation for the Audit Transformation" href="http://msdn.microsoft.com/en-us/library/ms141150.aspx">here for 2008</a> and <a title="SQL 2005 MSDN Documentation for the Audit Transformation" href="http:http://msdn.microsoft.com/en-us/library/ms141150(SQL.90).aspx//">here for 2005</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bimonkey.com/2009/05/the-audit-transformation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
