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: