Importing and Exporting with Directory Access Functions

The most basic directory operations can be performed by calling the BatchImport or BatchExport functions, specifying a minimum amount of information, and using default settings.

Note  The most important task when using directory access functions is to set the parameters used in function calls, such as the BEXPORT_PARMS structure used with the BatchExport function. For more information, see Structures.

    To invoke a basic export operation
  1. Export selected objects into a file using the BatchExport function. Designate the export file by setting the pszExportFile member of the BEXPORT_PARMS structure, which is the only parameter to BatchExport. In this file, you can use a header line that indicates which attributes to export and that will be read by the export function call. This function then exports its data to the export file by overwriting its contents, if any. The header line is preserved. In other words, the BatchExport function both reads from and writes to the export file.
  2. Designate the location in the directory information tree (DIT) from which objects are to be exported by specifying the basepoint container (with the pszBasePoint member and the pszContainer member) and the server (with pszServerName). See Controlling Export with BasePoint, Container, and Export Flags.

You can perform more complex export operations and tailor them to your specific needs, whether you are exporting every recipient in the DIT or a single object. You extend the capabilities of the directory access functions by setting values for control flags — an array of flags that comprise the dwFlags member. You can also assign values to other fields in the BEXPORT_PARMS structure. Some of these options are listed here:

In some cases, you need to combine the use of a parameter with a specific flag. For example, pass in a value for ulUSNBase to restrict an export to objects that have changed.

You can also fine-tune import operations. Here are several examples:

Note  Characters used in a distinguished name (DN) or in any string used to build a DN (such as pszBasePoint and pszContainer) must be in the 0x0020 to 0x007E range. Any characters outside this range are first mapped to ANSI. DNs are further mapped to 7-bit ASCII characters. When a function such as DAPIWrite has to map characters, it returns a warning.