SQL 2005 DDL Audit Sample Applications (1.0.0.0)

© sqldbatips.com, 2006. All rights reserved.

Contents

1.0 Introduction

2.0 DDL Audit Sample Installation

2.1  DDL Audit Sample Requirements

2.2  DDL Audit Sample Tested Environments

3.0 Using DDL Audit Admin

3.1  Creating the Central Audit Database

3.2  Deploying Auditing to Additional Instances

3.3  Deploying Audit Reports

3.4  Central Audit Database Archiving

4.0 Using DDL Audit Viewer

4.1  Connecting to an Audit Server

4.2  Managing Audit Servers List

4.2  DDL Audit Viewer Dependencies

5.0 Uninstalling DDL Auditing

6.0 Support and Feeback

7.0 Useful Links

8.0 Release History


1.0 Introduction

The SQL 2005 DDL Audit Sample is a collection of sample applications for configuring DDL (Data Definition Language) auditing on one or more SQL Server 2005 instances. These applications were first presented at the PASS 2006 Community Summit in my presentation Building a DDL Audit Solution using SQL Server 2005. They build on top of the Service Broker and Server Event Notification infrastructure available in SQL Server 2005 to provide a means of collecting all server and database DDL events in a central database for viewing and reporting. Full source code is provided for all sample applications to allow you to better understand the technologies and easily build on or modify these samples for use in your environment.

Key Components



2.0 DDL Audit Sample Installation

To install the SQL 2005 DDL Audit Sample simply unzip DDLAuditSample.zip to a folder on your local PC and run the enclosed setup application (DDL Audit Install.msi).

Note: This does NOT make any configuration changes to any SQL instances, it merely copies all the applications and source code to the following folder (by default) C:\Program Files\sqldbatips\DDL Audit Sample


The following folders will be created



2.1 DDL Audit Solution Requirements

In order to run the DDL Audit Sample applications you need to have the .NET Framework 2.0 and SQL Server Management Tools installed. To modify the source code you need to have a version of Visual Studio 2005 installed (other than SQL Server Business Intelligence Development Studio). Express versions of Visual Studio 2005 can be downloaded for free from here (Source code is C#).

 

2.2 DDL Audit Sample Tested Environments

SQL 2005 DDL Audit Sample applicationshas been tested with the following operating systems and SQL Server versions

SQL 2005 DDL Audit Sample applications are not localized and have only been tested against English versions of Operating Systems and SQL Server 2005.

3.0 Using DDL Audit Admin

You can launch DDL Audit Admin from the Start menu (Start>Program Files>sqldbatips.com>DDL Audit Sample>DDL Audit Admin) or by running C:\Program Files\sqldbatips\DDL Audit Sample\DDL Audit Admin\DDLAuditAdmin.exe.

Note: The user running the installation must have sysadmin rights on every SQL Server instance where auditing is to be deployed and local admin rights (or at least the right to enumerate services and service accounts) in Windows in order to be able to detect the SQL Server service account. All SQL Server instances to be audited must run under a domain user account unless auditing is being deployed to just one server (e.g. local development instance) in which case a local user account is sufficient.

3.1 Creating the Central Audit Database

In order to be able to collect DDL audit events from SQL 2005 instances the application creates a central audit database (DDLAuditDW).

3.2 Deploying Auditing to Additional Instances

In order to deploy DDL auditing to additional instances, switch to the Audited Servers tab of the application

3.3 Deploying Audit Reports

To deploy the sample audit reports which are used by the DDL Audit Viewer application open the Report project (either Start>Program Files>sqldbatips.com>DDL Audit Sample>DDL Audit Reports or C:\Program Files\sqldbatips\DDL Audit Sample\DDL Audit Reports\DDL Audit Reports.sln)

3.4 Central Audit Database Archiving

The installation of the central audit database (DDLAuditDW) creates a SQL Agent job called DDLAuditDW Archive Job which runs the stored procedure dbo.DoArchive. This process can be configured by modifying the following Name/Value pairs in the dbo.AuditConfig table in the DDLAuditDW database.

Name
Values
Description
RetentionType
DELETE or ARCHIVE
The default value is DELETE which means that all events with an EventDate less than the RetentionMonths value are deleted from the AuditDDL table. If set to ARCHIVE then events with an EventDate less than the RetentionMonths value are moved to the AuditDDLArchive table
RetentionMonths
3
This value is how long (in months) events are to be kept in the AuditDDL table before being deleted or archived

4.0 Using DDL Audit Viewer

You can launch DDL Audit Viewer from the Start menu (Start>Program Files>sqldbatips.com>DDL Audit Sample>DDL Audit Viewer) or by running C:\Program Files\sqldbatips\DDL Audit Sample\DDL Audit Viewer\DDLAuditViewer.exe.

4.1 Connecting to a Central Audit Server

In order to connect to a central audit server in order to view DDL events

4.2 Managing Audit Servers List

The Manage Servers dialog (File>Manage Servers) allows you to specify one or more central audit servers to connect to (e.g. DEV/QA/PROD)

4.3 DDL Audit Viewer Dependencies

The DDL Audit Viewer application has a number of dependencies on Name/Value pairs in the dbo.AuditConfig table in the DDLAuditDW database on the central audit server

Name
Default Value
Description
AuditSummaryReport
All Audit Summary
This is the name of the initial report displayed in DDL Audit Viewer when connecting to a central audit server
InstanceSummaryReport
Instance Summary
This is the name of the instance summary report displayed in DDL Audit Viewer when you select a specific instance. It takes an instance name as a report parameter
ReportPath
/DDL Audit Reports/
This is the full path to the audit reports used by DDL Audit Viewer. It should start and end with a forward slash
ReportServer
http://localhost/ReportServer
The url of the Reporting Services ReportService web service. This is supplied during deployment of the central audit database by the DDL Audit Admin application

5.0 Uninstalling DDL Auditing

To remove DDL Auditing from an instance (excluding the central server) use the following script

To remove DDL Auditing from the central server (make sure you have uninstalled it from all other instances first) use the following script

6.0 Support and Feeback

If you have any questions or feedback about the SQL 2005 DDL Audit Sample applications use the link below

7.0 Useful Links

8.0 Release History

Date
Build
Description
10/12/2006
1.0.0.0
Initial public release

 

THIS APPLICATION AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE