DsBackupOpenFile function

[This function is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Beginning with Windows Vista, use Volume Shadow Copy Service (VSS) instead.]

The DsBackupOpenFile function opens the specified file and performs the client and server operations necessary to prepare the file for backup.


HRESULT DsBackupOpenFile(
  _In_  HBC           hbc,
  _In_  LPCTSTR       szAttachmentName,
  _In_  DWORD         cbReadHintSize,
  _Out_ LARGE_INTEGER *pliFileSize


hbc [in]

Contains the backup context handle obtained with the DsBackupPrepare function.

szAttachmentName [in]

Pointer to a null-terminated string that specifies the name of the backup file to open.

cbReadHintSize [in]

Contains the possible size, in bytes, of the buffer passed as the pvBuffer argument in the DsBackupRead function. The backup functions use this value as a hint to optimize the network traffic. This value must be a multiple of 8192 and must be greater than or equal to 24576.

pliFileSize [out]

Pointer to a LARGE_INTEGER value that receives the size, in bytes, of the backup file opened.

Return value

Returns S_OK if the function is successful or a Win32 or RPC error code otherwise. The following list lists other possible error codes.


The caller does not have the proper access privileges to call this function. The DsSetAuthIdentity function can be used to set the credentials to use for the backup and restore functions.


hbc, szAttachmentName, or pliFileSize are invalid.


Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Unicode and ANSI names
DsBackupOpenFileW (Unicode) and DsBackupOpenFileA (ANSI)

See also


Backing Up an Active Directory Server

Directory Backup Functions