2

我想了解用于获取有关 Exchange Server 的更多信息的 LDAP 查询。我有兴趣了解更多关于数据可用性组、关于它们的统计信息和复制状态等。我知道有一些 CmdLets,但我想避免使用 PowerShell。

我想知道从 Active Directory for Exchange Server 获取相同信息的任何可能方式。

4

1 回答 1

0

这是一个很酷的主意!

这一切都在下面的配置分区中:

CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=xx,DC=xx。

下面的 C# 代码将检索服务器角色,应该可以帮助您入门。

角色信息来自这里

        using (DirectoryEntry de = new DirectoryEntry("LDAP://RootDSE"))
        {
            var NamingContext = de.Properties["configurationNamingContext"][0];
            using (DirectoryEntry de_NC = new DirectoryEntry("LDAP://" + NamingContext))
            {
                using (DirectorySearcher ds = new DirectorySearcher(de_NC))
                {
                    ds.PropertiesToLoad.Add("cn");

                    ds.Filter = "(&(objectCategory=msExchExchangeServer)(msExchCurrentServerRoles:1.2.840.113556.1.4.803:=2))";
                    Output("Mailbox Role Servers:", ds, "cn");

                    ds.Filter = "(&(objectCategory=msExchExchangeServer)(msExchCurrentServerRoles:1.2.840.113556.1.4.803:=4))";
                    Output("CAS Role Servers:", ds, "cn");

                    ds.Filter = "(&(objectCategory=msExchExchangeServer)(msExchCurrentServerRoles:1.2.840.113556.1.4.803:=16))";
                    Output("Unified Messaging Role Servers:", ds, "cn");

                    ds.Filter = "(&(objectCategory=msExchExchangeServer)(msExchCurrentServerRoles:1.2.840.113556.1.4.803:=32))";
                    Output("Hub Transport Role Servers:", ds, "cn");

                    ds.Filter = "(&(objectCategory=msExchExchangeServer)(msExchCurrentServerRoles:1.2.840.113556.1.4.803:=64))";
                    Output("Edge Transport Role Servers:", ds, "cn");
                }
            }
        }


    static void Output(string Titel, DirectorySearcher ds, string Property)
    {
        Console.WriteLine(Titel);
        SearchResultCollection src = ds.FindAll();
        foreach (SearchResult RoleServer in src)
        {
            Console.WriteLine(RoleServer.Properties[Property][0].ToString());
        }
        if (src.Count < 1)
            Console.WriteLine("---");

        Console.WriteLine();
    }
于 2013-01-08T20:28:44.457 回答