The Microsoft Exchange Server address book provider provides access to directory objects through the MAPI address book interface. Using MAPI, you can create and delete directory objects, as well as view and change their attributes.
The main requirement for manipulating directory objects through the Microsoft Exchange Server address book provider is that MAPI entry identifiers be generated for the objects. An entry identifier can be created from the object's distinguished name, using the HrCreateDirEntryIDEx function.
If your program modifies several objects, its code may look like this:
OpenEntry (object 1)
SetProps(property list)
GetProps(property list)
SaveChanges( )
Release()
OpenEntry (object 2)
To read or write several object properties at once, it is best to perform the task with a single IMAPIProp::SetProps or IMAPIProp::GetProps call. This is more efficient than repeatedly calling these methods and specifying a single property to read or write in each call.
Through the Microsoft Exchange Server address book provider, you can access directory objects that correspond to the five MAPI display types. The following table lists these display types, along with the most commonly used MAPI interface.
Corresponding Directory Objects and MAPI Display Types
MAPI Display Type | Directory Object Type | MAPI Interface |
---|---|---|
Distribution List | Distribution-List | IDistList |
User | Mail-Recipient | IMailUser |
Remote User | Remote-Address | IMailUser |
Agent | Mailbox-Agent | IMailUser |
Forum | Public-Folder | IMailUser |
The IMailUser interface inherits methods from the IMAPIProp interface. Use the methods of these interfaces to access directory objects and their attributes. An object-valued attribute, which is an attribute whose type is PT_OBJECT, is seen by MAPI as a table. The attribute's values are members of the table. To access these values, use the IMAPITable interface, which is obtained by calling IMAPIProp::OpenProperty on the property of interest.
As with directory access import commands, the directory automatically updates the object's USN after it is modified using MAPI commands. Using MAPI commands in the directory has no effect on the information store. For more information about USNs, see Exporting Objects and Using Directory Access Functions.