2015-10-06 88 views
0

賬號或郵箱,我有兩個用戶[email protected][email protected]。我試圖訪問b的郵箱用戶a使用EWS託管API。用戶a對b的郵箱擁有完全權限。我甚至可以從Outlook Web Access的帳戶中打開b的郵箱。Microsoft.Exchange.WebServices.Data.ServiceResponseException:無法訪問拋出其用戶fullright訪問

但是,當試圖訪問B的郵箱我得到這個異常。

Microsoft.Exchange.WebServices.Data.ServiceResponseException:無法使用 來訪問帳戶或郵箱。

下面是相關代碼

  var mailbox = new Mailbox("[email protected]"); 
      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>[email protected]</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的賬戶中打開b的郵箱時,異常消失,我可以從代碼中訪問b的郵箱。再後來,當我必須再次手動從OWA帳戶中打開b的郵箱並且循環繼續時,同樣的異常會再次重新出現。 任何想法?

回答

0

這可能與Impersonation有關,嘗試把這一行代碼:

service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, [email protected]); 

有3種方式,使用戶能夠訪問其他用戶的郵箱:

  1. 通過添加代表和指定每個代表的權限。
  2. 通過直接修改文件夾權限。
  3. 通過使用模擬。

每種方式都有其侷限性,您可以從該鏈接中找到詳細信息。

+0

我正在採取委派方式,並且未啓用ApplicationImpersonation用戶。代表團方式適用於許多其他賬戶(不同的域名,例如[email protected]和[email protected])。只有一個領域,我面臨這個問題。 – Sameer

1

好的。它看起來像是如果你有配置問題,可能會出現錯誤,可能有多個用戶具有相同的SMTP地址。舉例來說,如果您有多個使用[email protected]列爲SMTP地址,您可能會看到此錯誤。

+0

我將無法在明天之前驗證這一點。但我有很多其他的smtp地址[email protected],[email protected]等等.....對於所有這些地址,我在從@公司訪問時遇到同樣的錯誤。COM。所以具有相同smtp的多個用戶可能會導致所有其他用戶失敗? – Sameer