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

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.

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