HOWTO: Obtain the Exchange Directory Hierarchy Programmatically

ID: Q186334


The information in this article applies to:
  • Microsoft Exchange Server, versions 4.0, 5.0, 5.5


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:
  • Kernel32.lib


  • User32.lib


  • Advapi32.lib


  • Edkevent.lib


  • Gdi32.lib


  • Winspool.lib


  • Comdlg32.lib


  • Advapi32.lib


  • Shell32.lib


  • Ole32.lib


  • Oleaut32.lib


  • Uuid.lib


  • Edkmapi.lib


  • Edkdebug.lib


  • Msgemit.lib


  • Mapi32.lib


  • Edkguid.lib


  • Edkutils.lib


  • Gwmain.lib


  • Rtflib32.lib


  • Addrlkup.lib


  • Version.lib


  • Msvcrt.lib


  • Mblogon.lib


  • Exchinst.lib


  • Newpst.lib


  • Sadapi.lib


  • Rpcrt4.lib


  • Rpcndr.lib


  • Rpcns4.lib


Exclude the following Libraries:
  • Libc.lib


  • Libcd.lib


Additional query words: kbDSupport kbEDK kbMsg

Keywords :
Version : winnt:4.0,5.0,5.5
Platform : winnt
Issue type : kbhowto


Last Reviewed: November 5, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.