CertSrvBackupPrepareW function (certbcli.h)
The CertSrvBackupPrepare function is used to prepare a Certificate Services server for backup operations.
Syntax
HRESULT CERTBCLI_API CertSrvBackupPrepareW(
[in] WCHAR const *pwszServerName,
[in] ULONG grbitJet,
[in] ULONG dwBackupFlags,
[out] HCSBC *phbc
);
Parameters
[in] pwszServerName
A pointer to the machine name of the server to prepare for online backup. This name can be the NetBIOS name or the DNS name.
[in] grbitJet
Value used by the database engine; this value should be set to zero.
[in] dwBackupFlags
Specifies the backup type. This can be either of the following values.
Value | Meaning |
---|---|
|
Backup the Certificate Services database, logs and related files. |
|
Backup the log files only. |
[out] phbc
A pointer to a Certificate Services backup context handle (HCSBC).
Return value
The return value is an HRESULT. A value of S_OK indicates success, and *phbc will be set to an HCSBC which can be used by other Certificate Services backup APIs.
Remarks
Before a Certificate Services backup can occur, it is necessary to create an HCSBC by means of CertSrvBackupPrepare. The resulting HCSBC is a necessary parameter of Certificate Services backup functions which can be used to list, open, read, and close files, as well as truncate the log files.
To execute this call, you must have the backup privilege. For details, see Setting the Backup and Restore Privileges.
Examples
WCHAR * wszServer = L"MyCertServerMachine";
FNCERTSRVBACKUPPREPAREW* pfnBackupPrepare;
char * szBackPrepFunc = "CertSrvBackupPrepareW";
HINSTANCE hInst=0;
HCSBC hCSBC=NULL;
HRESULT hr=0;
// Load the DLL.
hInst = LoadLibrary(L"Certadm.dll");
if ( NULL == hInst )
{
printf("Failed LoadLibrary, error=%d\n",
GetLastError() );
exit(1); // Or other appropriate error action.
}
// Get the address for the desired function.
pfnBackupPrepare = (FNCERTSRVBACKUPPREPAREW*)GetProcAddress( hInst,
szBackPrepFunc );
if ( NULL == pfnBackupPrepare )
{
printf("Failed GetProcAddress - %s, error=%d\n",
szBackPrepFunc,
GetLastError() );
exit(1); // Or other appropriate error action.
}
// Prepare CertServ for backup.
hr = pfnBackupPrepare(wszServer,
0,
CSBACKUP_TYPE_FULL,
&hCSBC);
if (FAILED(hr))
{
printf("Failed pfnBackupPrepare call [%x]\n", hr);
exit(1); // Or other appropriate error action.
}
// Use the HCSBC for backup operations.
// ...
// When done processing, release the HCSBC context
// by calling CertSrvBackupEnd (not shown here).
// ...
// Done processing, free the DLL.
if (hInst)
FreeLibrary(hInst);
Requirements
Requirement | Value |
---|---|
Minimum supported client | None supported |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | certbcli.h (include Certsrv.h) |
Library | Certadm.lib |
DLL | Certadm.dll |