Web-service-API to administrate Exchange-Accounts

本文关键字:Exchange-Accounts administrate to Web-service-API | 更新日期: 2023-09-27 18:13:09

是否有一个web-service-API,我可以使用它来管理exchange-server 2010上的帐户(更新到2013是可能的)?

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

ECP (Exchange Control Panel):虽然提供了所有预期的功能,但它似乎并没有提供web服务,而只是一个浏览器前端。我希望能避开浏览器抓取。

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

有什么建议吗?

Web-service-API to administrate Exchange-Accounts

我没有找到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身份验证。