DetachDatabase method

Detaches a database from the audit store.

Syntax

void DetachDatabase(
AuditStoreDatabase classdatabase
)

Parameters

Specify the following parameter when using this method.

Parameter Description

database

The database object of the audit store database that you want to detach.

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