如何使用 EWS 从 Exchange 获取所有用户

How to get all users from Exchange with EWS

我想使用 EWS 从 xchange 服务器获取所有用户。我已经弄清楚如何获得所有房间和所有约会。但我特别需要所有用户,因此我可以从我的应用程序中增删改查用户。这可能吗?我没有在网上找到任何例子。请告知如何实现这一目标。

soap 请求如何查找用户 CRUD 操作?

在 Exchange 2013 及更高版本上,您可以将 FindPeople 操作与您要访问的地址列表的 GUID 结合使用(例如,对于全球地址列表,您可以使用 GAL 的 guid)。

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Header>
        <RequestServerVersion Version="Exchange2013_SP1" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
      </soap:Header>
      <soap:Body>
        <FindPeople xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
          <IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning" />
          <ParentFolderId>
            <AddressListId Id="5c90c254-2463-4256-bf52-60d82e6baa44" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
          </ParentFolderId>
        </FindPeople>
      </soap:Body>
    </soap:Envelope>

然后您可以使用 Offset

将结果分页返回

一个问题是您无法使用 EWS 获得所需的 GUID,您需要使用 Exchange Management Shell 中的 Get-GlobalAddressList cmdlet https://technet.microsoft.com/en-us/library/aa996579(v=exchg.160).aspx 这将 return 请求所需的 GUID。

干杯 格伦

回应您的一些评论:

使用 Exchange 2010 的一个好方法(此方法在我的网络中有效,我们 运行 E2010)是通过与安装了 Exchange 管理工具的中心交换服务器进行交互式 Powershell 会话,运行宁powershell版本2.0.

目标如下:

  1. 使用 New-PSSession 创建一个新的交互式会话
  2. 导入该会话以使远程 cmdlet 本地化到您的本地主机。

.

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YOURFQDNOFTHEEXCHANGESERVERHERE/powershell
Import-PSSession $session | out-null

然后您将能够使用 Exchange 管理可用的东西(cmdlet)Shell/EMC,就像您远程登录到 Exchange 服务器本身一样。

此方法直接从 Exchange 管理工具安装目录本身提取,这就是 Exchange 管理 Shell 实际上将 modules/functions/extended cmdlet 功能导入常规 powershell 主机的方式。

从那时起,我强烈建议您使用 google/search Exchange 2010 powershell commandlet,因为它们是非常有用和强大(没有双关语意)的工具,可帮助管理 AD 对象、Exchange 对象、等等