繁体   English   中英

Microsoft.Exchange.WebServices.Data.ServiceResponseException:无法访问为具有完全访问权限的用户抛出的帐户或邮箱

[英]Microsoft.Exchange.WebServices.Data.ServiceResponseException: Unable to access an account or mailbox thrown for user having fullright access

我有两个用户a@company.comb@company.com 我正在尝试使用EWS托管API用户a访问b的邮箱 用户a对b的邮箱具有完全权限。 我什至可以通过Outlook Web Access从a的帐户打开b的邮箱。

但是,当尝试访问b的邮箱时,出现此异常。

Microsoft.Exchange.WebServices.Data.ServiceResponseException:无法访问帐户或邮箱。

这是相关的代码

            var mailbox = new Mailbox("b@company.com");
            var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox);
            Folder lyncFolder;
            try
            {
                // Getting  ServiceResponseException : Unable to access an account or mailbox                              
                lyncFolder = Folder.Bind(_exchangeService, folderId);
            }
            catch (ServiceResponseException ex)
            {
                _logger.Error(ex);

                    throw;

            }

这是请求跟踪

<Trace Tag=\"EwsRequest\" Tid=\"7\" Time=\"2015-10-07 11:04:47Z\" Version=\"15.00.0847.030\">
  <?xml version=\"1.0\" encoding=\"utf-8\"?>
  <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soap:Header>
      <t:RequestServerVersion Version=\"Exchange2013_SP1\" />
    </soap:Header>
    <soap:Body>
      <m:GetFolder>
        <m:FolderShape>
          <t:BaseShape>AllProperties</t:BaseShape>
        </m:FolderShape>
        <m:FolderIds>
          <t:DistinguishedFolderId Id=\"inbox\">
            <t:Mailbox>
              <t:EmailAddress>b@company.com</t:EmailAddress>
            </t:Mailbox>
          </t:DistinguishedFolderId>
        </m:FolderIds>
      </m:GetFolder>
    </soap:Body>
  </soap:Envelope>
</Trace>

这是响应轨迹

<Trace Tag="EwsResponse" Tid="7" Time="2015-10-07 04:19:05Z" Version="15.00.0847.030">
  <?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
      <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorMailboxConfiguration</faultcode>
      <faultstring xml:lang="en-US">Unable to access an account or mailbox.</faultstring>
      <detail>
        <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorMailboxConfiguration</e:ResponseCode>
        <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">Unable to access an account or mailbox.</e:Message>
      </detail>
      </s:Fault>
    </s:Body>
  </s:Envelope>
</Trace>

这是响应头

Transfer-Encoding : chunked
request-id : 26ee43ea-6444-4f6c-abb0-f041fdb6dde6
X-CalculatedBETarget : BLUPR01MB116.prod.exchangelabs.com
X-BackEndHttpStatus : 500
x-EwsHandler : GetFolder
X-DiagInfo : BLUPR01MB116
X-BEServer : BLUPR01MB116
X-FEServer : SIXPR04CA0091
Cache-Control : private
Content-Type : text/xml; charset=utf-8
Date : Wed, 07 Oct 2015 10:54:15 GMT
Set-Cookie : exchangecookie=e6f7d9dad36b40ad918050eefbd3d25c; path=/
Server : Microsoft-IIS/8.0
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET

我观察到的行为是当我从OWA手动从a的帐户打开b的邮箱时,异常消失了,我可以从代码访问b的邮箱。 再后来,当我不得不再次从OWA手动从a的帐户中打开b的邮箱时,同样的异常再次随机出现,并且循环继续。 任何想法?

好。 如果您遇到配置问题,则可能会出现该错误,可能有多个具有相同SMTP地址的用户。 因此,例如,如果您将b@company.com作为SMTP地址使用了b@company.com ,则可能会看到此错误。

这可能与Impersonation有关,请尝试将以下行放入代码中:

service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, b@company.com);

有3种方法可以使用户访问其他用户的邮箱:

  1. 通过添加委托并为每个委托指定权限。
  2. 通过直接修改文件夹权限。
  3. 通过使用模拟。

每种方式都有其局限性,您可以从该链接中找到详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM