AuditStore class

Manages AuditStore objects.

Syntax

class AuditStore

Properties

The AuditStore class provides the following properties:

Property Property
ActiveDatabase property Gets the active audit store database.
Databases property Gets the list of the audit store databases.
Name property (audit store) Gets the display name of the audit store.

Methods

The AuditStore class provides the following methods:

Method Description
AddDatabase method Creates a new audit store database and attaches the database to the audit store using default settings.
AddDatabaseByScript method Creates a new audit store database and attaches the database to the audit store using custom settings specified in SQL scripts.
AttachDatabase method Attaches an existing audit store database to the audit store.
ChangeActiveDatabase method Changes which database is currently active in the audit store.
DetachDatabase method Detaches a database from the audit store.
GetDatabase method Retrieves the audit store database object given the database display name.

Discussion

An audit store can have multiple databases attached, but only one can be active at a time. This class allows you to manage the audit store, including attaching and detaching databases and specifying which database is active. To get information about the attached databases, use the AuditStoreDatabase class and the AuditStoreDatabases class.

See also

ActiveDatabase Property

Gets the active audit store database.

Syntax

AuditStoreDatabase class ActiveDatabase {get;}

Return Value

Returns the active audit store database.

Discussion

An audit store can have multiple databases attached, but only one can be active at a time.

See also

Databases Property

Gets the list of the audit store databases.

Syntax

AuditStoreDatabases class Databases {get;}

Return Value

Returns the list of the audit store databases.

Discussion

This property returns a list of all the databases attached to the audit store.

See also

Name property (audit store)

Gets the display name of the audit store.

Syntax

string Name {get;}

Return Value

Returns the display name of the audit store.

Discussion

The display name of the audit store is used in the Audit Manager console. It is distinct from the display name of the active database.

See also

AddDatabase Method

Creates a new audit store database and attaches the database to the audit store using default settings.

Syntax

AuditStoreDatabase class AddDatabase(

string name,

string serverName,

string database

)

Parameters

Return Value

Returns the AuditStoreDatabase object of the new audit store database.

Errors

The AddDatabase method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

  • Centrify.DirectAudit.Common.Logic.UnauthorizedException if you do not have the Manage Database permission on the audit store or you do not have the SQL Server permission to create SQL Server databases on the Microsoft SQL Server instance.

  • Centrify.DirectAudit.Common.Logic.AlreadyExistsException if the specified display name is already being used by another audit store database, or the specified database name is already being used by another database in the Microsoft SQL Server instance.

Discussion

Use this method to create a new audit store database and attach it to the audit store. To customize the database or attach an existing database to the audit store, use one of the methods listed in the “See also” section.

Example

The following code sample argument illustrates the use of AuditStore.AddDatabase:

...
strInstallationName = wscript.arguments.item(0)
strAuditStoreName = wscript.arguments.item(1)
strServerName = wscript.arguments.item(2)
strDatabaseName = wscript.arguments.item(3)
SET objAuditStoreDatabase = objAuditStore.GetDatabase(strDatabaseName)
IF NOT objAuditStoreDatabase IS NOTHING THEN
wscript.echo "Audit Store database '" & strDatabaseName & "' already exists."
wscript.quit
END IF
' Create a new audit store database and attach to the audit store
SET objAuditStoreDatabase = objAuditStore.AddDatabase(strDatabaseName, & _
strServerName, strDatabaseName)
IF objAuditStoreDatabase IS NOTHING THEN
wscript.echo "Failed to add audit store database '" & strDatabaseName & "'."
wscript.quit
END IF
wscript.echo "Created and attached audit store database '" & strDatabaseName & "'."

See also

AddDatabaseByScript Method

Creates a new audit store database and attaches the database to the audit store using custom settings specified in SQL scripts.

Syntax

AuditStoreDatabase class AddDatabaseByScript(

string name,

string serverName,

string database,

string scriptFile1,

string scriptFile2

)

Parameters

Return Value

Returns the AuditStoreDatabase object of the new audit store database.

Errors

The AddDatabaseByScript method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

  • Centrify.DirectAudit.Common.Logic.UnauthorizedException if you do not have the Manage Database permission on the audit store or you do not have the SQL Server permission to create SQL Server databases on the Microsoft SQL Server instance.

  • Centrify.DirectAudit.Common.Logic.AlreadyExistsException if the specified display name is already being used by another audit store database, or the specified database name is already being use by another database in the Microsoft SQL Server instance.

Discussion

The database name you specify in the database parameter is substituted for the keyword #database in the SQL script. To create a new database using standard settings or to attach an existing database to the audit store, use on the methods listed in the “See also” section.

Example

The following code sample illustrates using AuditStore.AddDatabaseByScript in a script:

...

' Create a new audit store database and attach to the audit store
SET objAuditStoreDatabase = objAuditStore.AddDatabaseByScript(strDatabaseName, & _
strServerName, strDatabaseName, strServerScriptFile, strDatabaseScriptFile)

IF objAuditStoreDatabase IS NOTHING THEN
wscript.echo "Failed to add audit store database '" & strDatabaseName & "'."
wscript.quit
END IF
wscript.echo "Created and attached audit store database '" & strDatabaseName & "'."

See also

AttachDatabase method

Attaches an existing audit store database to the audit store.

Syntax

AuditStoreDatabase class AttachDatabase(

string name,

string server,

string database

)

Parameters

Return Value

Returns the AuditStoreDatabase object of the attached audit store database.

Errors

The AttachDatabase method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

  • Centrify.DirectAudit.Common.Logic.UnauthorizedException if you do not have the Manage Database permission on the audit store or you do not have the SQL Server permission to create SQL Server databases on the Microsoft SQL Server instance.

  • Centrify.DirectAudit.Common.Logic.AlreadyExistsException if the specified display name is already being used by another audit store database, or the specified database name is already being use by another database in the Microsoft SQL Server instance.

Discussion

Use this method if you already have a database that you want to attach to the audit store. To create a new database and attach it to the audit store, use the AddDatabase or AddDatabaseByScript method instead.

Example

The following code sample illustrates using AuditStore.AttachDatabase in a script:

...

' Attach an audit store database to the audit store
SET objAuditStoreDatabase = objAuditStore.AttachDatabase(strDatabaseName, & _
strServerName, strDatabaseName)

IF objAuditStoreDatabase IS NOTHING THEN
wscript.echo "Failed to attach audit store database '" & strDatabaseName & "'."

wscript.quit
END IF
wscript.echo "Attached audit store database '" & strDatabaseName & "'."

See also

ChangeActiveDatabase Method

Changes which database is currently active in the audit store.

Syntax

void ChangeActiveDatabase(

AuditStoreDatabase classdatabase

)

Parameters

Errors

The ChangeActiveDatabase method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

  • Centrify.DirectAudit.Common.Logic.UnauthorizedException if you do not have the Manage Database permission on the audit store or you do not have the SQL Server permission to create SQL Server databases on the Microsoft SQL Server instance.

Discussion

An audit store can have multiple databases attached, but only one can be active at a time. Once you have made a database inactive by calling this method, you cannot make it active again. You cannot detach the active database.

Example

The following code sample illustrates using AuditStore.ChangeActiveDatabase in a script:

' Change active Audit Store database
objAuditStore.ChangeActiveDatabase(objAuditStoreDatabase)
wscript.echo "Changed active database to '" & objAuditStore.ActiveDatabase.Name & "'."

See also

DetachDatabase Method

Detaches a database from the audit store.

Syntax

void DetachDatabase(

AuditStoreDatabase classdatabase

)

Parameters

Errors

The DetachDatabase method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

  • Centrify.DirectAudit.Common.Logic.UnauthorizedException if you do not have the Manage Database permission on the audit store or you do not have the SQL Server permission to create SQL Server databases on the Microsoft SQL Server instance.

Discussion

An audit store can have multiple databases attached, but only one can be active at a time. You cannot detach the active database.

Example

The following code sample illustrates using AuditStore.DetachDatabase in a script:

...

' Detach any Audit Store databases older than 2 years
FOR EACH objDatabase IN objAuditStore.Databases
IF DateDiff("d", today, objDatabase.ActiveEndTime) > 728 THEN
objAuditStore.DetachDatabase(objDatabase)
wscript.echo "Detached Audit Store database '" & objDatabase.Name & "'."
END IF

GetDatabase Method

Retrieves the audit store database object given the database display name.

Syntax

AuditStoreDatabase class GetDatabase(

string displayname

)

Parameters

Return Value

Returns the AuditStoreDatabase object of the specified database.

Errors

The GetDatabase method may throw one of the following exceptions:

  • Centrify.DirectAudit.Common.Logic.AuthenticationException if you do not have permission to connect to the Microsoft SQL Server instance that hosts the management database or you do not have permission to connect to the Microsoft SQL Server instance of the audit store database to be created.

  • Centrify.DirectAudit.Common.Logic.ConnectDatabaseException if you cannot connect to the Microsoft SQL Server instance either because the instance is not running or does not allow remote connections.

Discussion

Use this method to obtain the audit store database object of any database attached to the audit store if you already have the audit store database display name.

Example

The following code sample illustrates using AuditStore.GetDatabase in a script:

...

today = Date
strDatabaseName = strDatabaseName & "-" & Year(today) & "-" & Month(today) & _

& "-" & Day(today)

SET objAuditStoreDatabase = objAuditStore.GetDatabase(strDatabaseName)

IF NOT objAuditStoreDatabase IS NOTHING THEN
wscript.echo "Audit Store database '" & strDatabaseName & "' already exists."
wscript.quit
END IF