用于管理Exchange帐户的Web服务API

时间:2014-07-15 18:27:51

标签: c# web-services exchange-server

我是否可以使用网络服务API来管理Exchange Server 2010上的帐户(可以更新到2013)?

到目前为止我发现了什么:

ECP(Exchange控制面板):虽然提供了所有预期的功能,但它似乎不提供Web服务,而只提供浏览器前端。我希望绕过浏览器。

EWS(Exchange Web服务):作为一个Web服务,它似乎只提供标准客户端功能,而无需管理帐户本身。

有什么建议吗?

托管C#-API会很好......

1 个答案:

答案 0 :(得分:0)

我没有找到webservices来执行此操作,而是使用ExchangePowerShell。 为此,您需要安装Exchange管理工具(例如,如此处所述http://exchangeserverpro.com/exchange-2010-install-management-tools/)和对System.Management.Automation.dll的引用(可通过NuGet获得)。

为了帮助您入门,请在下面找到我用作概念验证的代码。

WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://{HostnameOfExchangeServer}/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", (PSCredential) null);
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
using (PowerShell powershell = PowerShell.Create()) {
    powershell.AddCommand("Get-MailboxServer");
    runspace.Open();
    powershell.Runspace = runspace;
    return powershell.Invoke();
}

由于PSCredential设置为null,因此使用正常的Windows身份验证。