title: EWS Error Accessing Public Folders - Exchange 2010 With Replicated Exchange 2003 Public Folders
body: <p>We currently have the following setup:</p>
  
  <p>Single Exchange 2003 Server – Also Running the Exchange 2010 Public Folder Database
  Single Exchange 2010 Server – Also Running the Exchange 2010 Public Folder Database &amp; Client Access role (e.g. with EWS, OWA, etc..)</p>
  
  <p>We have public folders held on 2010 and public folders held on 2003. We are replicating the public folders both ways between servers (configured through the public folder management console). </p>
  
  <p>We have a test account with a mailbox on Exchange 2010 that has the highest level of privileges (domain admin and also “organization management” within Exchange). This user is called “grey”. The user has been granted explicitly full ownership of all public folders in both the 2010 public folder database and the 2003 public folder database. We can confirm that we can access and use the public folders perfectly OK through OWA and also Outlook.</p>
  
  <p>The problem we are having is accessing the public folders through Exchange. We can confirm that accessing normal folders within the mailbox itself is not an issue and is working fine.</p>
  
  <p>When running the following simple code snippet to loop through the public folders we are hitting an error:</p>
  
  <pre><code>    public static void PublicFolderTest()
      {
          // Connect to Exchange Web Services 
          ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
          service.Url = new Uri("https://gblonxch11/EWS/Exchange.asmx");
          service.Credentials = new WebCredentials("grey@home.local", "Welcome1");
          System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) =&gt; true);
  
          FolderView folderView = new FolderView(int.MaxValue);
  
          FindFoldersResults findResults = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView);
  
          if (findResults.Folders.Count &gt; 0)
          {
              Console.WriteLine("Looping Through Public Folders");
          }
  
      }
  </code></pre>
  
  <p>This code snippet is failing with the FindFolders call with the following error stack:</p>
  
  <pre><code>Microsoft.Exchange.WebServices.Data.ServiceResponseException was unhandled
  Message=The mailbox that was requested doesn't support the specified RequestServerVersion.
  Source=Microsoft.Exchange.WebServices
  StackTrace:
         at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
         at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.InternalExecute()
         at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
         at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, FolderView view, ServiceErrorHandling errorHandlingMode)
         at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId, FolderView view)
         at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(WellKnownFolderName parentFolderName, FolderView view)
         at testspace.Program.PublicFolderTest() in F:\Source Code\TestApp\TestApp\Program.cs:line 40
         at testspace.Program.Main(String[] args) in F:\Source Code\TestApp\TestApp\Program.cs:line 26
         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ThreadHelper.ThreadStart()
    InnerException: 
  </code></pre>
  
  <p>We have also turned on “Failed Request Tracing” in IIS for the EWS application. The internal stack trace is attached as file “UsingExchangeVersion2010.zip”. The error stack is inconclusive – but there are errors relating to authentication issues internally in the stack. </p>
  
  <p>We also tried setting the ExchangeVersion used by the EWS managed API to be Exchange2007_SP1:</p>
  
  <pre><code>    public static void PublicFolderTest()
      {
          // Connect to Exchange Web Services 
          ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
          service.Url = new Uri("https://gblonxch11/EWS/Exchange.asmx");
          service.Credentials = new WebCredentials("grey@home.local", "Welcome1");
          System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) =&gt; true);
  
          FolderView folderView = new FolderView(int.MaxValue);
  
          FindFoldersResults findResults = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView);
  
          if (findResults.Folders.Count &gt; 0)
          {
              Console.WriteLine("Looping Through Public Folders");
          }
  
      }
  </code></pre>
  
  <p>This results in an error but a slightly different error:</p>
  
  <pre><code>Microsoft.Exchange.WebServices.Data.ServiceResponseException was unhandled
  Message=An internal server error occurred. The operation failed.
  Source=Microsoft.Exchange.WebServices
  StackTrace:
         at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
         at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.InternalExecute()
         at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
         at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, FolderView view, ServiceErrorHandling errorHandlingMode)
         at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId, FolderView view)
         at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(WellKnownFolderName parentFolderName, FolderView view)
         at testspace.Program.PublicFolderTest() in F:\Source Code\TestApp\TestApp\Program.cs:line 40
         at testspace.Program.Main(String[] args) in F:\Source Code\TestApp\TestApp\Program.cs:line 26
         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ThreadHelper.ThreadStart()
    InnerException: 
  </code></pre>
  
  <p>The stack trace internally within IIS for the EWS is attached as file “UsingExchangeVersion2007.zip”. Again the internal stack trace is inconclusive – but again appears to be related to authentication issues. </p>
  
  <p>Can anyone advise whether this has been seen before and perhaps what the root cause might be?</p>