Importing and Manipulating Objects

You can perform basic data import operations by calling the BatchImport function, specifying a minimum amount of information, and using default settings. This function can read a series of instructions from a file called an import file or import script. These instructions manipulate existing objects in the directory or import new objects into the directory. They are executed in a single bulk operation, with optional line-by-line control.

    To execute a simple import operation
  1. Indicate the name of the import file with the pszImportFile member of the BIMPORT_PARMS structure.
  2. Indicate an import destination in the directory information tree (DIT) with the pszBasePoint and pszContainer members of the BIMPORT_PARMS structure.

From this basic operation you can add functionality by specifying additional parameters, setting control flags, or using a template object. Template objects are explained in Using Template Objects.

Instructions in the import script can create new objects in the directory, make changes to existing directory objects and their attributes, or both. Therefore, although the file is called an import file, it can be used to create, update, and delete objects.

Using an import file

An import file is an ASCII text file that contains attributes of objects for the data being imported or manipulated, as well as the data itself. Elements are separated by commas or another character. The file is self-defining, which means that the first line of the file contains the attribute names and the remaining lines contain the data. Any attribute associated with directory objects can be manipulated by directory access functions using an import file. For more information, see Files Used with Directory Access Functions and File Formats.

For each line in an import file, the import functions can perform the following types of actions:

Import files are used only for batch import in association with the BatchImport function. In contrast to BatchImport, the DAPIWrite function uses the pAttributes member as a parameter that is a pointer to a DAPI_ENTRY structure containing names (such as Proxy-Address, Comment, Home-Server, or Display-Name) of attributes to be imported. DAPIWrite also uses the pValues member as a pointer to a DAPI_ENTRY structure containing the actual attribute values to be set on the DIT entry.

Note  Multivalued properties can be imported two ways. The imported data can overwrite the existing data, or the new data can be appended to the existing data. This choice is made by setting the DAPI_MODIFY_REPLACE_PROPERTIES control flag in the BIMPORT_PARMS structure, when calling the BatchImport function. Setting this flag causes existing data to be overwritten. In Microsoft Exchange Server version 5.0 (RC1) or later, importing a new value that differs in case from an existing value will replace the old value, regardless of whether you have chosen to append or overwrite.