Finding an Object in the Directory

To find an object in the directory, you can either use the DAPIWrite or BatchImport directory access function, or you can use the MAPI address book interface.

    To add a directory object using DAPIWrite

Call the DAPIWrite directory access function. Pass DAPI_WRITE_CREATE in the dwFlags parameter to indicate you want to create an object. (If the object already exists, the call to DAPIWrite fails.) In the pAttributes and pValues parameters, pass pointers to DAPI_ENTRY structures that contain the names of attributes to be written to the directory and the values for those attributes, respectively.

    To add a directory object using BatchImport

Call the BatchImport directory access function and specify an import file in the pszImportFile member of the BIMPORT_PARMS structure.

    To find a directory object using MAPI functions
  1. Find the Global Address List.
  2. Call IMAPITable::Restrict on the Global Address List. To do this, you first build a restriction structure, specifying the properties you know about the object you want to find. You could, for example, include the Display-Name of the object in this restriction structure. This call returns a handle to a table, and an IMAPITable interface.
  3. Call IMAPITable::FindRows to find the specific row representing the object you want to find. The columns in the table correspond to the properties of the object, one of which is its entry identifier. You can then read this entry identifier and use it later to open the object.