title: Impersonation in a multi-forest environment throws ErrorNonExistentMailbox
body: <p>I am trying to access Exchange in a resource forest with a user that is in the user forest, and impersonate mailboxes that are in the resource forest.</p>
  
  <p>For this, we have created a contact <a href="https://blogs.technet.microsoft.com/exchange/2008/04/18/cross-forest-exchange-impersonation-where-the-rubber-meets-the-road/" rel="nofollow noreferrer">as described here</a> and added it to the <code>ApplicationImpersonation</code> security group <a href="https://ingogegenwarth.wordpress.com/2015/02/04/exchangeimpersonation-and-rbac-in-a-multi-forest-scenario/" rel="nofollow noreferrer">as described here</a>.</p>
  
  <p>At first, the impersonation seems to be working, since the error </p>
  
  <blockquote>
    <p>The account does not have permission to impersonate the requested user.</p>
  </blockquote>
  
  <p>has gone away as soon as the account has been added to the <code>ApplicationImpersonation</code> group.</p>
  
  <p>However, the impersonating user still cannot access the folders it should access; the error thrown is </p>
  
  <blockquote>
    <p>The SMTP address has no mailbox associated with it.</p>
  </blockquote>
  
  <p>Now, that error message seems to be wrong, not only since AutoDiscover returned that very server as the Exchange server associated to that very mailbox. But what is the reason for this error message? Find attached an EWS trace.</p>
  
  <pre><code>AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Starting SCP lookup for domainName='maildomain.com', root path=''
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Searching for SCP entries in LDAP://CN=Configuration,DC=resourceforest,DC=local
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Scanning for SCP pointers Domain=maildomain.com
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  No SCP pointers found for 'Domain=maildomain.com' in configPath='CN=Configuration,DC=resourceforest,DC=local'
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Scanning for SCP urls for the current computer Site=Default-First-Site-Name
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Adding (prio 1) 'https://autodiscover.maildomain.com/Autodiscover/Autodiscover.xml' for the 'Site=Default-First-Site-Name' from 'LDAP://CN=EXCHSRV,CN=Autodiscover,CN=Protocols,CN=EXCHSRV,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=EXCH,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=resourceforest,DC=local' to the top of the list (exact match)
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Determining which endpoints are enabled for host autodiscover.maildomain.com
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Request error: The remote server has returned an error: (401) Not authorized.
  &lt;/Trace&gt;
  
  AutodiscoverConfiguration: &lt;Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  Host returned enabled endpoint flags: Legacy, Soap, WsSecurity, OAuth
  &lt;/Trace&gt;
  
  AutodiscoverRequestHttpHeaders: &lt;Trace Tag="AutodiscoverRequestHttpHeaders" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  POST /autodiscover/autodiscover.svc HTTP/1.1
  Content-Type: text/xml; charset=utf-8
  Accept: text/xml
  User-Agent: ExchangeServicesClient/15.00.0913.015
  
  
  &lt;/Trace&gt;
  
  AutodiscoverRequest: &lt;Trace Tag="AutodiscoverRequest" Tid="19" Time="2017-12-06 11:47:15Z" Version="15.00.0913.015"&gt;
    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;soap:Envelope xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;soap:Header&gt;
        &lt;a:RequestedServerVersion&gt;Exchange2010_SP2&lt;/a:RequestedServerVersion&gt;
        &lt;wsa:Action&gt;http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettings&lt;/wsa:Action&gt;
        &lt;wsa:To&gt;https://autodiscover.maildomain.com/autodiscover/autodiscover.svc&lt;/wsa:To&gt;
      &lt;/soap:Header&gt;
      &lt;soap:Body&gt;
        &lt;a:GetUserSettingsRequestMessage xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover"&gt;
          &lt;a:Request&gt;
            &lt;a:Users&gt;
              &lt;a:User&gt;
                &lt;a:Mailbox&gt;existingmailbox@maildomain.com&lt;/a:Mailbox&gt;
              &lt;/a:User&gt;
            &lt;/a:Users&gt;
            &lt;a:RequestedSettings&gt;
              &lt;a:Setting&gt;InternalEwsUrl&lt;/a:Setting&gt;
              &lt;a:Setting&gt;ExternalEwsUrl&lt;/a:Setting&gt;
            &lt;/a:RequestedSettings&gt;
          &lt;/a:Request&gt;
        &lt;/a:GetUserSettingsRequestMessage&gt;
      &lt;/soap:Body&gt;
    &lt;/soap:Envelope&gt;
  &lt;/Trace&gt;
  
  AutodiscoverResponseHttpHeaders: &lt;Trace Tag="AutodiscoverResponseHttpHeaders" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  HTTP/1.1 200 OK
  Transfer-Encoding: chunked
  request-id: 2595c423-85bb-4e19-95c0-69fff1b770cf
  X-CalculatedBETarget: exchsrv.resourceforest.local
  X-DiagInfo: EXCHSRV
  X-BEServer: EXCHSRV
  Persistent-Auth: true
  X-FEServer: EXCHSRV
  Cache-Control: private
  Content-Type: text/xml; charset=utf-8
  Date: Wed, 06 Dec 2017 11:44:00 GMT
  Set-Cookie: X-BackEndCookie=S-1-5-21-1233478190-3624727864-577162443-1630=u56Lnp2ejJqBnJ7LyJ3LncnSzJvGnNLLzsma0p6eysbSnpnIns6czp3Mx5vOgYHNz87H0s/O0s/Kq87OxcvLxc/O; expires=Fri, 05-Jan-2018 11:44:01 GMT; path=/autodiscover; secure; HttpOnly
  Server: Microsoft-IIS/8.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  
  
  &lt;/Trace&gt;
  
  AutodiscoverResponse: &lt;Trace Tag="AutodiscoverResponse" Tid="19" Time="2017-12-06 11:47:15Z" Version="15.00.0913.015"&gt;
    &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"&gt;
      &lt;s:Header&gt;
        &lt;a:Action s:mustUnderstand="1"&gt;http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettingsResponse&lt;/a:Action&gt;
        &lt;h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/2010/Autodiscover" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
          &lt;h:MajorVersion&gt;15&lt;/h:MajorVersion&gt;
          &lt;h:MinorVersion&gt;0&lt;/h:MinorVersion&gt;
          &lt;h:MajorBuildNumber&gt;1347&lt;/h:MajorBuildNumber&gt;
          &lt;h:MinorBuildNumber&gt;0&lt;/h:MinorBuildNumber&gt;
          &lt;h:Version&gt;Exchange2013_SP1&lt;/h:Version&gt;
        &lt;/h:ServerVersionInfo&gt;
      &lt;/s:Header&gt;
      &lt;s:Body&gt;
        &lt;GetUserSettingsResponseMessage xmlns="http://schemas.microsoft.com/exchange/2010/Autodiscover"&gt;
          &lt;Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
            &lt;ErrorCode&gt;NoError&lt;/ErrorCode&gt;
            &lt;ErrorMessage /&gt;
            &lt;UserResponses&gt;
              &lt;UserResponse&gt;
                &lt;ErrorCode&gt;NoError&lt;/ErrorCode&gt;
                &lt;ErrorMessage&gt;No error.&lt;/ErrorMessage&gt;
                &lt;RedirectTarget i:nil="true" /&gt;
                &lt;UserSettingErrors /&gt;
                &lt;UserSettings&gt;
                  &lt;UserSetting i:type="StringSetting"&gt;
                    &lt;Name&gt;InternalEwsUrl&lt;/Name&gt;
                    &lt;Value&gt;https://exchsrv.maildomain.com/EWS/Exchange.asmx&lt;/Value&gt;
                  &lt;/UserSetting&gt;
                  &lt;UserSetting i:type="StringSetting"&gt;
                    &lt;Name&gt;ExternalEwsUrl&lt;/Name&gt;
                    &lt;Value&gt;https://exchsrv.maildomain.com/EWS/Exchange.asmx&lt;/Value&gt;
                  &lt;/UserSetting&gt;
                &lt;/UserSettings&gt;
              &lt;/UserResponse&gt;
            &lt;/UserResponses&gt;
          &lt;/Response&gt;
        &lt;/GetUserSettingsResponseMessage&gt;
      &lt;/s:Body&gt;
    &lt;/s:Envelope&gt;
  &lt;/Trace&gt;
  
  EwsRequestHttpHeaders: &lt;Trace Tag="EwsRequestHttpHeaders" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  POST /EWS/Exchange.asmx HTTP/1.1
  Content-Type: text/xml; charset=utf-8
  Accept: text/xml
  User-Agent: ExchangeServicesClient/15.00.0913.015
  Accept-Encoding: gzip,deflate
  
  
  &lt;/Trace&gt;
  
  EwsRequest: &lt;Trace Tag="EwsRequest" Tid="19" Time="2017-12-06 11:47:15Z" Version="15.00.0913.015"&gt;
    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;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/"&gt;
      &lt;soap:Header&gt;
        &lt;t:RequestServerVersion Version="Exchange2010_SP2" /&gt;
        &lt;t:ExchangeImpersonation&gt;
          &lt;t:ConnectingSID&gt;
            &lt;t:SmtpAddress&gt;existingmailbox@maildomain.com&lt;/t:SmtpAddress&gt;
          &lt;/t:ConnectingSID&gt;
        &lt;/t:ExchangeImpersonation&gt;
      &lt;/soap:Header&gt;
      &lt;soap:Body&gt;
        &lt;m:GetFolder&gt;
          &lt;m:FolderShape&gt;
            &lt;t:BaseShape&gt;AllProperties&lt;/t:BaseShape&gt;
          &lt;/m:FolderShape&gt;
          &lt;m:FolderIds&gt;
            &lt;t:DistinguishedFolderId Id="calendar"&gt;
              &lt;t:Mailbox&gt;
                &lt;t:EmailAddress&gt;existingmailbox@maildomain.com&lt;/t:EmailAddress&gt;
              &lt;/t:Mailbox&gt;
            &lt;/t:DistinguishedFolderId&gt;
          &lt;/m:FolderIds&gt;
        &lt;/m:GetFolder&gt;
      &lt;/soap:Body&gt;
    &lt;/soap:Envelope&gt;
  &lt;/Trace&gt;
  
  EwsResponseHttpHeaders: &lt;Trace Tag="EwsResponseHttpHeaders" Tid="19" Time="2017-12-06 11:47:15Z"&gt;
  HTTP/1.1 500 Internal Server Error
  Transfer-Encoding: chunked
  request-id: 1027a792-caae-4b8b-99b9-33f35233e2e6
  X-CalculatedBETarget: exchsrv.resourceforest.local
  X-DiagInfo: EXCHSRV
  X-BEServer: EXCHSRV
  Cache-Control: private
  Content-Type: text/xml; charset=utf-8
  Set-Cookie: exchangecookie=d43cb59780624405a5f6874f3c5186f9; expires=Thu, 06-Dec-2018 11:44:01 GMT; path=/; HttpOnly,X-BackEndCookie=S-1-5-21-1233478190-3624727864-577162443-1630=u56Lnp2ejJqBnJ7LyJ3LncnSzJvGnNLLzsma0p6eysbSnpnIns6czp3Mx5vOgYHNz87H0s/O0s/Kq87OxcvLxc/O; expires=Fri, 05-Jan-2018 11:44:01 GMT; path=/EWS; secure; HttpOnly
  Server: Microsoft-IIS/8.5
  X-AspNet-Version: 4.0.30319
  Persistent-Auth: true
  X-Powered-By: ASP.NET
  X-FEServer: EXCHSRV
  Date: Wed, 06 Dec 2017 11:44:00 GMT
  
  
  &lt;/Trace&gt;
  
  EwsResponse: &lt;Trace Tag="EwsResponse" Tid="19" Time="2017-12-06 11:47:15Z" Version="15.00.0913.015"&gt;
    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;s:Body&gt;
        &lt;s:Fault&gt;
          &lt;faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types"&gt;a:ErrorNonExistentMailbox&lt;/faultcode&gt;
          &lt;faultstring xml:lang="de-DE"&gt;The SMTP address has no mailbox associated with it.&lt;/faultstring&gt;
          &lt;detail&gt;
            &lt;e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"&gt;ErrorNonExistentMailbox&lt;/e:ResponseCode&gt;
            &lt;e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"&gt;The SMTP address has no mailbox associated with it.&lt;/e:Message&gt;
            &lt;t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"&gt;
              &lt;t:Value Name="SmtpAddress"&gt;existingmailbox@maildomain.com&lt;/t:Value&gt;
            &lt;/t:MessageXml&gt;
          &lt;/detail&gt;
        &lt;/s:Fault&gt;
      &lt;/s:Body&gt;
    &lt;/s:Envelope&gt;
  &lt;/Trace&gt;
  </code></pre>