Enumerating Storage Groups and Stores
Enumerating Storage Groups and Stores
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The following example shows how you can use each CDO for Exchange Management (CDOEXM) object to enumerate storage groups, public and mailbox stores in the storage groups, and the folder trees in which the stores appear. Various parts of this sample can be useful for locating such objects in the Exchange 2000 server.
Visual Basic
' This subroutine will find all the stores on the local machine. Sub EnumerateStore() Dim iExs As New CDOEXM.ExchangeServer Dim isg As New CDOEXM.StorageGroup Dim ipsDB As New CDOEXM.PublicStoreDB Dim imbxDB As New CDOEXM.MailboxStoreDB Dim ift As New CDOEXM.FolderTree Dim ds2 As IDataSource2 Set ds2 = iExs Debug.Print Chr(13) + Chr(13) + Chr(13) + "=================================" Dim server_nm As String server_nm = Environ("COMPUTERNAME") 'The computer name is the servername. ds2.Open server_nm Debug.Print "ExchangeVersion = " + iExs.ExchangeVersion Debug.Print "DirectoryServer = " + iExs.DirectoryServer Dim storegroup As Variant Dim pubstore As Variant Dim mbx As Variant For Each storegroup In iExs.StorageGroups Debug.Print "StorageGroup Distinguished Name = " + storegroup + Chr(13) isg.DataSource.Open storegroup For Each pubstore In isg.PublicStoreDBs Debug.Print "Public Store = " + pubstore ipsDB.DataSource.Open pubstore Debug.Print " Name = " + ipsDB.name + Chr(13) Debug.Print "FolderTree = " + ipsDB.FolderTree ift.DataSource.Open ipsDB.FolderTree Debug.Print " RootFolderURL = " + ift.RootFolderURL Debug.Print " Name = " + ift.name + Chr(13) Next 'public store For Each mbx In isg.MailboxStoreDBs Debug.Print "Mailbox = " + mbx imbxDB.DataSource.Open mbx Debug.Print " Name = " + imbxDB.name + Chr(13) Next 'mailbox Next 'storage group Set iExs = Nothing Set isg = Nothing Set ipsDB = Nothing Set imbxDB = Nothing Set ift = Nothing End Sub
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.