Accessing PT_OBJECT Properties through MAPI

Many directory properties are of the type PT_OBJECT. To access the properties of this type declared in EMSABTAG.H, use the IMAPITable interface. The following procedure illustrates this method by accessing the Manager (PR_EMS_AB_MANAGER) and Reports (PR_EMS_AB_REPORTS) properties.

    To read a directory object's Manager and Reports properties
  1. Create a MAPI entry identifier by calling HrCreateDirEntryId. In this call, pass the distinguished name (DN) of the directory object that contains the property in the lpszAddress parameter. .
    hr = HrCreateDirEntryId(
    szDN,
    &cbEntryID,
    &lpEntryID); 
     
  2. Call the IMAPISession::OpenEntry method using the entry identifier returned in step 1 to open an IMAPIProp interface on the object.
    LPMAPIPROP  lpObject   = NULL;
    
    hr = MAPICALL(lpSession)->OpenEntry(
    lpSession,
    cbEntryID,
    lpEntryID,
    NULL,
    0,
    &ulObjType,
    (LPUNKNOWN FAR *)&lpObject); 
     

    For each of the PR_EMS_AB_MANAGER and PR_EMS_AB_REPORTS properties you want to access, perform the following steps:

  3. Call the IMAPIProp::OpenProperty method to open an IMAPITable interface on the property.
    LPMAPITABLE   lpTable  = NULL;
    
    hr = MAPICALL(lpObject)->OpenProperty(
    lpObject,
    ulPropTag,
    (LPIID)&IID_IMAPITable, 
    0,
    MAPI_DEFERRED_ERRORS,
    (LPUNKNOWN *)&lpTable);
     
  4. Call the MAPI HrQueryAllRows function to retrieve the rows in the table. For the PR_EMS_AB_MANAGER property, there will be a single row containing the manager's properties, such as PR_DISPLAY_NAME and PR_ENTRYID. For the PR_EMS_AB_REPORTS property, there will be one row for each report.
    LPSRowSet   lpRows   = NULL;
     
    hr = HrQueryAllRows(lpTable, NULL, NULL, NULL, 0, &lpRows);