Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems return (401) Unauthorized error on client, but works on the webserver RRS feed

  • Question

  • Intranet site gets user's appointment and email inbox from Exchange server when browsing the site on the webserver. When browsing the site from a client machine the following error is returned:

    Error while retrieving emails: The request failed. The remote server returned an error: (401) Unauthorized.. StackTrace: at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request) at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute() at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems[TItem](IEnumerable`1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode) at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ItemView view)


    SSP.Exchange.WebControls.Webparts.WebPart.DoImpersonation() is set before extracting emails.

    var url = “https://<exchangeserver>/ews/Exchange.asmx”;

    var version = (ExchangeVersion)Enum.Parse(typeof(ExchangeVersion), Exchange2010);

    var service = new ExchangeService(version) { Url = new Uri(url), UseDefaultCredentials = true };

    service.UseDefaultCredentials = true;

    var view = new ItemView(10); // Return only ten items.

    var findResults = service.FindItems(WellKnownFolderName.Inbox, view);


    Site is running with windows authentication.

    SPN is registered for the webserver.

    Both exchange server and webserver has “Trust this computer for delegation to any service (Kerbos only)” selected.

    Tuesday, May 24, 2011 3:44 PM

All replies

  • See if you can find the request (with the 401 response) in the server's iis log file.  It might be a different kind of 401 (there are several), such as 'IP address rejected'.

    Outlook Web Access For PDA , OWA For WAP
    email a@t leederbyshire d.0.t c.0.m
    Wednesday, May 25, 2011 1:32 PM
  • I was troubleshooting this error, and learned that I needed to use the full email address to log in:

    rather than simply


    Hopefully this helps somebody else hitting this error.

    Wednesday, February 22, 2012 4:12 PM