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

Specify the following parameters when using this method.

Parameter Description

name

The display name of the audit store database.

servername

The SQL Server instance name of the audit store database.

database

The database name of the audit store database.

scriptFile1

The file path of the SQL script for server setup.

scriptFile2

The file path of the SQL script for database setup.

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