Friends, Technology, Web2.0 - What I am reading

    [Home] [Recent] [Site Map]

   

枚举Exchange Server、SotreGroups和MailStore

通过以下代码枚举列出所有的Exchange Server、StoreGroups和MailStore,并获取每个MailStore中Mailbox的数量。本段C#代码为http://www.ureader.com/message/513012.aspx一文中的VBNET代码改写而成,在Exchange 2003环境中测试通过。

通过这段代码,结合创建 Mailbox 的代码,可以实现获取Exchange环境的Server、StoreGroup、MailStore和Mailbox信息,或在指定Store(比如在所有Store中最少Mailbox的那个,或者人为指定目标Store)中创建Mailbox。

        protected void Page_Load(object sender, EventArgs e)

        {

            DirectoryEntry RootDSE = new DirectoryEntry("LDAP://RootDSE");

            string rootPath = "LDAP://" + RootDSE.Properties["configurationNamingContext"].Value.ToString();

            DirectoryEntry configContainer = new DirectoryEntry(rootPath);

 

            DirectorySearcher configSearcher = new DirectorySearcher(configContainer);

            configSearcher.SearchRoot = configContainer;

            configSearcher.Filter = "(objectCategory=msExchExchangeServer)";

 

            // Enumerate all Exchange Servers

            SearchResultCollection serverResults = configSearcher.FindAll();

            foreach (SearchResult serverResult in serverResults)

            {

                Response.Write("<br/><br/><font color=\"red\">=== Exchange Server: " + serverResult.GetDirectoryEntry().Properties["cn"].Value.ToString() + " ===</font><br/><br/>");

 

                SearchResultCollection storeGroups;

                SearchResultCollection stores;

                int mailboxCount;

 

                // Enumerate all Store Groups

                storeGroups = SearchContainer(serverResult.Properties["distinguishedName"][0].ToString(),

                    "(objectCategory=msExchStorageGroup)");

                foreach (SearchResult storeGroup in storeGroups)

                {

                    string storeGroupName = storeGroup.GetDirectoryEntry().Properties["cn"].Value.ToString();

                    Response.Write(storeGroupName + "<br/>");

 

                    mailboxCount = 0;

 

                    // Enumerate All Stores

                    stores = SearchContainer(storeGroup.Properties["distinguishedName"][0].ToString(),

                        "(objectCategory=msExchPrivateMDB)");

                    foreach (SearchResult store in stores)

                    {

                        Response.Write("&nbsp;&nbsp;" + store.GetDirectoryEntry().Properties["cn"].Value.ToString() + "<br/>");

                        Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;Number of Mailboxes: " +

                            store.GetDirectoryEntry().Properties["homeMDBBL"].Count.ToString() + "<br/>");

 

                        mailboxCount += store.GetDirectoryEntry().Properties["homeMDBBL"].Count;

                    }

 

                    string reportMsg = String.Format("Total Number of Mailboxes in Storage Group({0}): {1}<br/><br/>", storeGroupName, mailboxCount);

                    Response.Write(reportMsg);

                }

            }

        }

 

        private SearchResultCollection SearchContainer(string srvPath, string strFilter)

        {

            string ldapPath = "LDAP://" + srvPath;

            DirectoryEntry serverContainer = new DirectoryEntry(ldapPath);

 

            DirectorySearcher serverSearcher = new DirectorySearcher(serverContainer);

            serverSearcher.Filter = strFilter;

            serverSearcher.SearchScope = SearchScope.Subtree;

 

            serverSearcher.PropertiesToLoad.Add("cn");

            serverSearcher.PropertiesToLoad.Add("distinguishedName");

            serverSearcher.PropertiesToLoad.Add("homeMDBBL");

 

            SearchResultCollection results = serverSearcher.FindAll();

 

            return results;

        }


关于Exchange的收藏夹几个必备站点:


>>Source Link
>>Blog: joycode
>>Publish Date: 3/4/2007 8:01:36 AM
>>Keywords: exchange mailstore

Related Posts
>>Talking Exchange 2007 SP1... (Exchange/You Had Me At EHLO) #
    Talking Exchange 2007 SP1... We"re wrapping up our Beta of Exchange 2007 SP1 (to be released through TechNet plus this April), and as always we wanted to discuss it publicly here first. We are targe
>>Take the Jupiter/ClickZ Search Marketing Survey #
    The ClickZ Network, which includes Search Engine Watch, and JupiterResearch are now conducting our semi-annual Search Marketing 2007 executive survey. All search marketers are invited to participate i
>>Web News: Mozilla Manifesto, Offline Firefox, Yahoo IM/Mail, President 2.0, SNS APIs, Web Safety #
    - The Mozilla Manifesto; rather generic new manifesto. It reminds us of an old Jeff Bezos quote... when someone asked him "What do u think about Google"s moto - don"t be evil?" Bezos is said to have
>>The Attention Economy: An Overview #
    Written by Alex Iskold and edited by Richard MacManus digg_url = "http://digg.com/tech_news/The_Attention_Economy_An_Overview"; It is no secret that we live in an information overload age. The expl
>>Chinese Stock Market is Crazy #
    Maybe I am among the minority who didn"t notice the recent bull market trends in Chinese stock market. I heard some news, but never really look at what is happening in the market. Maybe people outside
>>IBM Launches Enterprise Social Networking Suite; Microsoft Helpfully Offers To Migrate IBM Customers Off It #
    The big news today is that IBM has released an enterprise social networking suite, called Lotus Connections. The NY Times explains: "Lotus Connections has five components — activities, commun
>>Paid Links That Are Truly Undetectable #
    Posted by randfishMr. Cutts recently wrote a story about so-called "undetectable spam," in which he countered any paid link building service"s claim that it could be truly undetectable to se
>>Online Poker - Too Competitive for White Hat SEO? #
    Posted by randfishLast week in London, I sat in on the organic listings forum, where myself, Dave Naylor, Greg Boser, Mikkel DeMib & Barry Lloyd fielded a slough of great questions. One exchange i
>>Mainstream Media Usage of Web 2.0 Services is Increasing #
    Written by Alex Iskold and edited by Richard MacManus I was reading a Time magazine article online today, entitled Marketing to your mind. This article was very provocative and I enjoyed reading it
>>Change.org: Social Network For Social Activism #
    Yet another social network launched publicly today, but this one called Change.org caught my eye for a couple of reasons. Firstly it"s for a great cause - enabling people to form communities around so

Other Posts:
>>免费的SQL Server培训录像(以及其他好的数据教程的指针)
>>基于.net技术的代码高亮显示组件
>>学习 CleanupStack
>>Visual C++的未来
>>告别 PC & windows 投奔 Mobile & Symbian
>>Refactor!™ for C++
>>技巧/诀窍:在ASP.NET中重写URL
>>如何使用VS2005的WebTest对webservice进行数据源绑定测试
>>WPF的文字阅读和Flow Document支持,以及新的纽约时报,每日邮报,和西雅图邮报Intelligencer的阅读器程序
>>ASP.NET AJAX和SharePoint
>>VS2003在安装MSSCCI 后无法访问原先的VSS
>>Vista 下安装 SQL Server 2005


Month Archives:

Top Tags:
Technology Internet Google Search Company & Product Profiles feature column letter comment Search Headlines analysis 互联网络 播客指南 国际政治 业界动态 application Startups BigCos 抓虾动态 Google/SEO Search Types: Local 业界信息 WebApp咨询 Web2.0 Review :: 评论 播客新闻 搜索引擎 用户体验 Yahoo Link Building Yahoo: Search Ads SEO 搜索产品


@2007 All rights Reserved