📄 ntdsbcli.pas
字号:
{******************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ Directory Service Backup/Restore interface unit }
{ }
{ Portions created by Microsoft are }
{ Copyright (C) 1995-1999 Microsoft Corporation. }
{ All Rights Reserved. }
{ }
{ The original file is: ntdsbcli.h, released June 2000. }
{ The original Pascal code is: NtDsbCli.pas, released Dec 2000 }
{ The initial developer of the Pascal code is Marcel van Brakel }
{ (brakelm@bart.nl). }
{ }
{ Portions created by Marcel van Brakel are }
{ Copyright (C) 1999 Marcel van Brakel. }
{ }
{ Obtained through: }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{******************************************************************}
unit NtDsbCli;
{$WEAKPACKAGEUNIT}
{$HPPEMIT ''}
{$HPPEMIT '#include ":ntdsbcli.h"'}
{$HPPEMIT ''}
{$I WINDEFINES.INC}
interface
uses
WinType;
const
g_wszBackupAnnotation = 'NTDS Backup Interface';
{$EXTERNALSYM g_wszBackupAnnotation}
g_aszBackupAnnotation = 'NTDS Backup Interface';
{$EXTERNALSYM g_aszBackupAnnotation}
g_wszRestoreAnnotation = 'NTDS Restore Interface';
{$EXTERNALSYM g_wszRestoreAnnotation}
g_aszRestoreAnnotation = 'NTDS Restore Interface';
{$EXTERNALSYM g_aszRestoreAnnotation}
{$IFDEF UNICODE}
g_szBackupAnnotation = g_wszBackupAnnotation;
{$EXTERNALSYM g_szBackupAnnotation}
g_szRestoreAnnotation = g_wszRestoreAnnotation;
{$EXTERNALSYM g_szRestoreAnnotation}
{$ELSE}
g_szBackupAnnotation = g_aszBackupAnnotation;
{$EXTERNALSYM g_szBackupAnnotation}
g_szRestoreAnnotation = g_aszRestoreAnnotation;
{$EXTERNALSYM g_szRestoreAnnotation}
{$ENDIF}
// Type of Backup passed to DsBackupPrepare()
// BACKUP_TYPE_FULL: Requesting backup of the complete DS (DIT, Log files, and Patch files)
// BACKUP_TYPE_LOGS_ONLY: Requesting backup of only the log files
// BACKUP_TYPE_INCREMENTAL: Requesting incremental backup i.e. backing up only changes that happened since last backup
BACKUP_TYPE_FULL = $01;
{$EXTERNALSYM BACKUP_TYPE_FULL}
BACKUP_TYPE_LOGS_ONLY = $02;
{$EXTERNALSYM BACKUP_TYPE_LOGS_ONLY}
BACKUP_TYPE_INCREMENTAL = $04; // not supported in product1
{$EXTERNALSYM BACKUP_TYPE_INCREMENTAL}
// Type of Restore passed to DsRestorePrepare()
// RESTORE_TYPE_AUTHORATATIVE: The restored version wins throughout the enterprise
// RESTORE_TYPE_ONLINE: Restoration is done when NTDS is online.
// RESTORE_TYPE_CATCHUP: The restored version is reconciled through the standard reconciliation logic so that the
// restored DIT can catchup with the rest of the enterprise.
RESTORE_TYPE_AUTHORATATIVE = $01;
{$EXTERNALSYM RESTORE_TYPE_AUTHORATATIVE}
RESTORE_TYPE_ONLINE = $02; // not supported in product1
{$EXTERNALSYM RESTORE_TYPE_ONLINE}
RESTORE_TYPE_CATCHUP = $04; // this is the default restore mode
{$EXTERNALSYM RESTORE_TYPE_CATCHUP}
// Setting the current log # to this value would disable incremental/differential backup
BACKUP_DISABLE_INCREMENTAL = DWORD($ffffffff);
{$EXTERNALSYM BACKUP_DISABLE_INCREMENTAL}
// BFT is the bit flag used to represent file types (directory/dit/logfile/etc.)
// We keep them as a character so that we can append/prepend them to the actual file
// path. The code in the Backup API's rely on the fact that values 0-256 in 8 bit ascii
// map to the values 0-256 in unicode.
type
{$IFDEF UNICODE}
BFT = WCHAR;
{$EXTERNALSYM BFT}
{$ELSE}
BFT = CHAR;
{$EXTERNALSYM BFT}
{$ENDIF}
// Bit flags:
// BFT_DIRECTORY - indicates path specified is a directory
// BFT_DATABASE_DIRECTORY - indicates that file goes into database directory
// BFT_LOG_DIRECTORY - indicates that the file goes into log directory
const
BFT_DIRECTORY = $80;
{$EXTERNALSYM BFT_DIRECTORY}
BFT_DATABASE_DIRECTORY = $40;
{$EXTERNALSYM BFT_DATABASE_DIRECTORY}
BFT_LOG_DIRECTORY = $20;
{$EXTERNALSYM BFT_LOG_DIRECTORY}
// Following combinations are defined for easy use of the filetype and the directory into
// into which it goes
BFT_LOG = BFT($01 or BFT_LOG_DIRECTORY);
BFT_LOG_DIR = BFT($02 or BFT_DIRECTORY);
BFT_CHECKPOINT_DIR = BFT($03 or BFT_DIRECTORY);
BFT_NTDS_DATABASE = BFT($04 or BFT_DATABASE_DIRECTORY);
BFT_PATCH_FILE = BFT($05 or BFT_LOG_DIRECTORY);
BFT_UNKNOWN = BFT($0F);
// #include <ntdsbmsg.h>
// Backup Context Handle
type
HBC = Pointer;
{$EXTERNALSYM HBC}
PEDB_RSTMAPA = ^EDB_RSTMAPA;
{$EXTERNALSYM PEDB_RSTMAPA}
tagEDB_RSTMAPA = record
szDatabaseName: PChar;
szNewDtabaseName: PChar;
end;
{$EXTERNALSYM tagEDB_RSTMAPA}
EDB_RSTMAPA = tagEDB_RSTMAPA;
{$EXTERNALSYM EDB_RSTMAPA}
TEdbRstMapA = EDB_RSTMAPA;
PEdbRstMapA = PEDB_RSTMAPA;
// required for NTDS unicode support.
// UNDONE: NYI
PEDB_RSTMAPW = ^EDB_RSTMAPW;
{$EXTERNALSYM PEDB_RSTMAPW}
tagEDB_RSTMAPW = record
wszDatabaseName: PWCHAR;
wszNewDatabaseName: PWCHAR;
end;
{$EXTERNALSYM tagEDB_RSTMAPW}
EDB_RSTMAPW = tagEDB_RSTMAPW;
{$EXTERNALSYM EDB_RSTMAPW}
TEdbRstMapW = EDB_RSTMAPW;
PEdbRstMapW = PEDB_RSTMAPW;
{$IFDEF UNICODE}
EDB_RSTMAP = EDB_RSTMAPW;
{$EXTERNALSYM EDB_RSTMAP}
PEDB_RSTMAP = PEDB_RSTMAPW;
{$EXTERNALSYM PEDB_RSTMAP}
TEdbRstMap = TEdbRstMapW;
PEdbRstMap = PEdbRstMapW;
{$ELSE}
EDB_RSTMAP = EDB_RSTMAPA;
{$EXTERNALSYM EDB_RSTMAP}
PEDB_RSTMAP = PEDB_RSTMAPA;
{$EXTERNALSYM PEDB_RSTMAP}
TEdbRstMap = TEdbRstMapA;
PEdbRstMap = PEdbRstMapA;
{$ENDIF}
{*************************************************************************************
Routine Description:
DsIsNTDSOnline
Checks to see if the NTDS is Online on the given server. This call is
guaranteed to return quickly.
Arguments:
[in] szServerName - UNC name of the server to check
[out] pfNTDSOnline - pointer to receive the bool result (TRUE if NTDS is
online; FALSE, otherwise)
Return Value:
ERROR_SUCCESS if the call executed successfully;
Failure code otherwise.
**************************************************************************************}
function DsIsNTDSOnlineA(szServerName: LPCSTR; var pfNTDSOnline: BOOL): HRESULT; stdcall;
{$EXTERNALSYM DsIsNTDSOnlineA}
function DsIsNTDSOnlineW(szServerName: LPCWSTR; var pfNTDSOnline: BOOL): HRESULT; stdcall;
{$EXTERNALSYM DsIsNTDSOnlineW}
{$IFDEF UNICODE}
function DsIsNTDSOnline(szServerName: LPCWSTR; var pfNTDSOnline: BOOL): HRESULT; stdcall;
{$EXTERNALSYM DsIsNTDSOnline}
{$ELSE}
function DsIsNTDSOnline(szServerName: LPCSTR; var pfNTDSOnline: BOOL): HRESULT; stdcall;
{$EXTERNALSYM DsIsNTDSOnline}
{$ENDIF}
{*************************************************************************************
Routine Description:
DsBackupPrepare
Prepares the DS for the online backup and returns a Backup Context Handle
which should be used in the subsequent calls to other backup functions.
Arguments:
[in] szBackupServer - UNC name of the server to be prepared for online backup
[in] grbit - flag to be passed to jet while backing up dbs
[in] btFlag - BACKUP_TYPE_FULL or BACKUP_TYPE_LOGS_ONLY
[out] ppvExpiryToken - pointer that will receive the pointer to the
Expiry Token associated with this backup; Client should save
this token and send it back through DsRestorePrepare() when
attempting a restore; allocated memory should be freed using
DsBackupFree() API by the caller when it is no longer needed.
[out] pcbExpiryTokenSize - pointer to receive the size of the expiry token
returned.
[out] phbc - pointer that will receive the backup context handle
Return Value:
One of the standard HRESULT success codes;
Failure code otherwise.
**************************************************************************************}
function DsBackupPrepareA(szBackupServer: LPCSTR; grbit: ULONG; btFlag: ULONG;
var ppvExpiryToken: PVOID; var pcbExpiryTokenSize: DWORD; var phbc: HBC): HRESULT; stdcall;
{$EXTERNALSYM DsBackupPrepareA}
function DsBackupPrepareW(szBackupServer: LPCWSTR; grbit: ULONG; btFlag: ULONG;
var ppvExpiryToken: PVOID; var pcbExpiryTokenSize: DWORD; var phbc: HBC): HRESULT; stdcall;
{$EXTERNALSYM DsBackupPrepareW}
{$IFDEF UNICODE}
function DsBackupPrepare(szBackupServer: LPCWSTR; grbit: ULONG; btFlag: ULONG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -