Thursday, April 9, 2015

SSRS - System.Web.Services.Protocols.SoapException: The permissions granted to user 'NT AUTHORITY\ANONYMOUS LOGON' are insufficient for performing this operation. when using ReportingServices2010.asmx in web applications with multiple authentication providers

I came across above exception when accessing SSRS reports using reporting services SOAP web service. Following is the detailed exception I received.

“System.ApplicationException: Failure in ActivateFeature for feature "<Feature>" on site: '<Site>' ---> System.Web.Services.Protocols.SoapException: The permissions granted to user 'NT AUTHORITY\ANONYMOUS LOGON' are insufficient for performing this operation. ---> Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: The permissions granted to user 'NT AUTHORITY\ANONYMOUS LOGON' are insufficient for performing this operation.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Microsoft.SqlServer.ReportingServices2010.ReportingService2010.CreateCatalogItem(String ItemType, String Name, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties,”

To resolve the issue I had to include following code segment when calling the web service

  1. ReportingService2010 service = new ReportingService2010();
  2. service.Credentials = CredentialCache.DefaultCredentials;
  3. service.Url = "http://sp13/_vti_bin/ReportServer/ReportService2010.asmx";
  4.  
  5. var authCookie = HttpContext.Current.Request.Cookies["FedAuth"];
  6. if (authCookie != null)
  7. {
  8.   var fedAuth = new Cookie(authCookie.Name, authCookie.Value, authCookie.Path, string.IsNullOrEmpty(authCookie.Domain) ? HttpContext.Current.Request.Url.Host : authCookie.Domain);
  9.   service.CookieContainer = new CookieContainer();
  10.   service.CookieContainer.Add(fedAuth);
  11. }

No comments: