The request failed with HTTP status 401: Unauthorized. Reporting Service ReportViewer (SharePoint Web Part)

I tried to use a Reporting Service Report Viewer in a custom web part in SharePoint that deployed successfully but when I tried to show report I got the following errorerror1

I tried to create ASP.Net Web Site solution with the same code that working properly so I am sure that the problem is not in code and it’s related to SharePoint Web Part.

I tried to check Authentication of SharePoint Site by following :

Start–> Administrative Tools –> IIS Manager then navigate to my SharePoint site then select Authentication .

IIS

At ASP.Net Impersonate it’s Enabled

IIS2

When I set Asp.Net Impersonate to false it’s worked properly:)

Unfortunately this solution affect on some features in my farm like search where I tried to run a full crawl search from central administration that not working  :(

I tried to check the Crawl Log where I got the following error:

error hresult fail has been returned from a call to a com component

SearchCrawl

I went back to Enable Asp.Net Impersonate , then I ran a Full Crawl search that working properly.but the main error back again:)

The request failed with HTTP status 401: Unauthorized.

I decided to disable Asp.Net Impersonate at the moment that I show my report therefore i will disable it via the following code in my web part.

public System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = System.Security.Principal.WindowsIdentity.Impersonate(System.IntPtr.Zero);
//Insert your code that runs under the security context of the authenticating user here.
impersonationContext.Undo();

If you have another solution please comment it.

Enjoy :)

6 thoughts on “The request failed with HTTP status 401: Unauthorized. Reporting Service ReportViewer (SharePoint Web Part)

  1. Ryan klick says:

    This isn’t a proper fix, in fact its more of a hack. Your having obvious issues with your authentication configuration on the server (are you using Kerberos? if so are all your spn’s setup correctly ) or potentially this is caused by incorrect formatting on the report URL. can you post your configuration of the report URL / location in the report viewer webpart.

  2. Ryan klick says:

    This isn’t a proper fix, in fact its more of a hack. Your having obvious issues with your authentication configuration on the server (are you using Kerberos? if so are all your spn’s setup correctly ) or potentially this is caused by incorrect formatting on the report URL. can you post your configuration of the report URL / location in the report viewer webpart. …

    • Ryan klick says:

      This isn’t a proper fix, in fact its more of a hack. Your having obvious issues with your authentication configuration on the server (are you using Kerberos? if so are all your spn’s setup correctly ) or potentially this is caused by incorrect formatting on the report URL. can you post your configuration of the report URL / location in the report viewer webpart. …

  3. mohamed rabie says:

    Hi , this error cause of security validation for other tiers in sharepoint, you need to stop page security validation , or add security digest control in the master page .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s