HOWTO: Obtain the Exchange Directory Hierarchy Programmatically

ID: Q186334

The information in this article applies to:

SUMMARY

When writing backup software it is sometimes useful to get the hierarchy of the Exchange directory. This article describes how to programmatically get the Exchange hierarchy of the Exchange Directory.

MORE INFORMATION

The sample below uses a BackupListNode structure to hold the hierarchy.

This is what that structure looks like:

   typedef struct _BackupListNode
   {
            struct _BackupListNode __RPC_FAR *pnodeNext;
            struct _BackupListNode __RPC_FAR *pnodeChildren;
            RPC_SZ szName;
   } BackupListNode;


   //Program Start

   /*******************************************************************
   // This code returns a BackupListNode structure that
   // represents the Organizational Hierarchy of Exchange.
   //******************************************************************

   #define UNICODE
   #define _UNICODE
   #include <SADAPI.H> //this header is included in the Platform SDK
   #include <TCHAR.h>

   void main(void)
   {
      BackupListNode*      pNode           =    NULL;
      RPC_SC               sc;
      PRPCBINDINFO         pBindInfo       =    new RPCBINDINFO;
      TCHAR                wszServer[256];

      ZeroMemory(pBindInfo, sizeof(RPCBINDINFO));

      // Replace "ExchangeServer" with the server name you
      // want to get the hierarchy from
      _tcscpy(wszServer, L"ExchangeServer");

      sc = SAD_ScBind(pBindInfo, wszServer);

      if (sc != ERROR_SUCCESS)   return;

      sc = SAD_ScGetBackupListNodeW(pBindInfo->wszServer, &pNode);

      // pNode will contain your entire hierarchy as seen by
      // the Server (wszServer)

      SAD_FreeBackupListNode(pNode);

      SAD_Unbind(pBindInfo);

      delete pBindInfo;
   }

To build use the following Libraries: Exclude the following Libraries: Additional query words: kbDSupport kbEDK kbMsg
Version           : WINDOWS:4.0,5.0,5.5
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: May 29, 1998