AttachDatabase method
Syntax
AuditStoreDatabase class AttachDatabase(
string name,
string server,
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 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 & "'."