【问题标题】:Why does EWS api returns ErrorNonExistentMailbox error?为什么 EWS api 返回 ErrorNonExistentMailbox 错误?
【发布时间】:2019-02-11 16:57:26
【问题描述】:

我在 Office 365 租户中有多个用户帐户,并分配了许可证。当我尝试使用 FindFolder operation 从包含下一个正文的 EWS API 获取用户邮箱中的信息(例如所有文件夹和项目)时:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
         xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2013"/>
    <t:ExchangeImpersonation>
      <t:ConnectingSID>
        <t:PrincipalName>name.surname@mydomain.be</t:PrincipalName>
      </t:ConnectingSID>
    </t:ExchangeImpersonation>
  </soap:Header>
  <soap:Body>
    <FindFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
      <FolderShape>
        <t:BaseShape>AllProperties</t:BaseShape>
      </FolderShape>
      <IndexedPageFolderView MaxEntriesReturned="1000" BasePoint="Beginning" Offset="0"/>
      <ParentFolderIds>
        <t:DistinguishedFolderId Id="msgfolderroot"/>
      </ParentFolderIds>
    </FindFolder>
  </soap:Body>
</soap:Envelope>

(name.surname@mydomain.be 是目标 Office 365 帐户的用户主体名称)我收到下一个正文的错误回复:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="1601" MinorBuildNumber="24" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  </s:Header>
  <s:Body>
    <m:FindFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:FindFolderResponseMessage ResponseClass="Error">
          <m:MessageText>Mailbox does not exist.</m:MessageText>
          <m:ResponseCode>ErrorNonExistentMailbox</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:FindFolderResponseMessage>
      </m:ResponseMessages>
    </m:FindFolderResponse>
  </s:Body>
</s:Envelope>

GetFolder operation 给了我同样的结果。

此错误通常是由未经许可的邮箱帐户引起的。但我所有的用户都有有效的 Exchange 许可证。为什么会收到这样的 ErrorNonExistentMailbox 错误响应?

【问题讨论】:

  • 您是指定邮箱的主 SMTP 地址还是代理地址之一?
  • 我使用 upn(用户主体名称)。

标签: outlook office365 exchangewebservices


【解决方案1】:

确保运行 EWS 脚本的帐户具有 ApplicationImpersonation 权限。因此,在这种情况下,您的帐户应该具有 ApplicationImpersonation 权限。

  • 导航到 O365 中的 EAC > 权限 > 将 ApplicationImpersonation 添加到 HygeneManagement RBAC 组,然后将您自己添加为成员。 这应该可以解决问题。

将来,如果您想对 ApplicationImpersonation 进行故障排除,您可以使用 EXRCA (https://testconnectivity.microsoft.com/) > O365 选项卡 > Microsoft Exchange Web 服务连接测试 > 选择“服务帐户访问(开发人员)”并运行测试。

如果您还有其他问题,请告诉我。

【讨论】:

  • 感谢您帮助我,但我不确定我们是否应该对 HygeneManagement RBAC Group 进行任何更改。 “此管理角色组的成员可以管理 Exchange 反垃圾邮件功能并授予防病毒产品与 Exchange 集成的权限。” - EAC 中 HygeneManagement 组的描述是什么。默认情况下,该组没有成员。此外,我的租户中有很多用户,对于其中一些用户,我得到了所描述的错误,但对于其中一些用户却没有(例如,我有 2 个具有相同设置的用户,其中一个有问题,而另一个没有拥有它)。
  • 您收到错误是因为应用程序无权模拟这些帐户,或者邮箱没有与之关联的 SMTP 地址。参考:support.microsoft.com/en-in/help/3006861/…
  • 我完全确定目标邮箱有与之关联的 SMTP 地址。如何确定应用程序是否有权模拟这些帐户?您链接的文章也适用于 Exchange Server 2013,但我使用的是在线 Exchange。
  • 将来如果您想对 ApplicationImpersonation 进行故障排除,您可以使用 EXRCA (testconnectivity.microsoft.com) > O365 选项卡 > Microsoft Exchange Web 服务连接测试 > 选择“服务帐户访问(开发人员)”并运行测试。
【解决方案2】:

我在使用exchange服务的时候遇到这个问题,邮箱在一些请求之后就禁止了请求(不知道为什么?!)。 (在 200 次请求后对我来说)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 2011-09-01
    • 2021-03-30
    • 1970-01-01
    • 2019-05-12
    • 2019-08-16
    • 2019-11-21
    相关资源
    最近更新 更多