CertSrvRestorePrepare function
The CertSrvRestorePrepare function prepares a Certificate Services instance for restore operations.
Syntax
HRESULT CertSrvRestorePrepare(
_In_ const WCHAR *pwszServerName,
_In_ ULONG dwRestoreFlags,
_Out_ HCSBC *phbc
);
Parameters
- pwszServerName [in]
-
A pointer to the computer name of the server to prepare for restore operations. This name can be the NetBIOS name or the DNS name.
- dwRestoreFlags [in]
-
A bitfield that represents the combination of values in the following table.
Value Meaning - CSRESTORE_TYPE_FULL
Restore Certificate Services database, logs, and related files.
- phbc [out]
-
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 is set to an HCSBC, which can be used by other Certificate Services restore APIs.
Remarks
Before a Certificate Services restore operation can occur, it is necessary to create an HCSBC by means of CertSrvRestorePrepare. This HCSBC can be used by various Certificate Services restore functions.
This function's name in Certadm.dll is CertSrvRestorePrepareW. You must use this form of the name when calling GetProcAddress. Also, this function is defined as type FNCERTSRVRESTOREPREPAREW in the Certbcli.h header file.
To execute this call, you must have the restore privilege. For more information, see Setting the Backup and Restore Privileges.
Examples
FNCERTSRVRESTOREPREPAREW* pfnRestorePrepare; char * szRestorePrepFunc = "CertSrvRestorePrepareW"; HCSBC hCSBC=NULL; HINSTANCE hInst=0; 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. pfnRestorePrepare = (FNCERTSRVRESTOREPREPAREW*)GetProcAddress( hInst, szRestorePrepFunc ); if ( NULL == pfnRestorePrepare ) { printf("Failed GetProcAddress - %s, error=%d\n", szRestorePrepFunc, GetLastError() ); exit(1); // Or other appropriate error action. } // Prepare CertServ for restoration. hr = pfnRestorePrepare(wszServer, CSRESTORE_TYPE_FULL, &hCSBC); if (FAILED(hr)) { printf("Failed pfnRestorePrepare call [%x]\n", hr); exit(1); // Or other appropriate error action. } // Use the HCSBC for restore operations. // ... // When done processing, release the HCSBC context // by calling CertSrvRestoreEnd (not shown here). // ... // Free the DLL. if (hInst) FreeLibrary(hInst);
Requirements
|
Minimum supported client |
None supported |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
CertSrvRestorePrepareW (Unicode) |
See also
- Setting the Backup and Restore Privileges
- Using the Certificate Services Backup and Restore Functions
- CertSrvRestoreEnd
- GetProcAddress