SSRS 2008 - HTTP Status 401: Unauthorized
I have a WPF application which is hosting a SSRS 2008 ReportView via a WindowsFormsHost control. I am trying to connect to a remote server to run a report, but I receive the following error: {"The request failed with HTTP status 401: Unauthorized."} [System.Net.WebException]: {"The request failed with HTTP status 401: Unauthorized."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: null Message: "The request failed with HTTP status 401: Unauthorized." Source: "Microsoft.ReportViewer.Common" StackTrace: " at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMethods() at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod(String methodname) at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionSSLForMethod(String methodname) at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn](RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod) at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(String Report, String HistoryID) at Microsoft.Reporting.WinForms.ServerReport.EnsureExecutionSession() at Microsoft.Reporting.WinForms.ServerReport.GetDataSources(Boolean& allCredentialsSet) at Microsoft.Reporting.WinForms.RSParams.GetDataSources(Boolean& allSatisfied) at Microsoft.Reporting.WinForms.RSParams.EnsureParamsLoaded(Boolean forceCredentialsShown, ReportParameterInfoCollection parameterInfos) at Microsoft.Reporting.WinForms.RSParams.EnsureParamsLoaded() at Microsoft.Reporting.WinForms.ReportViewer.RenderReportWithNewParameters(Int32 pageNumber)" TargetSite: {System.String[] GetSecureMethods()} Here's my environment: I have a Windows 2008 Server running SQL Server 2008. This server is a virtual machine running on Hyper-V in a Virtual Private LAN and I'm using RAAS to route traffic to this virtual via a static IP. I'm passing NetworkCredentials to the report for a user that can access and run reports. I can prove this by logging in to the report server via a browser with these same credentials. var report = reportViewer.ServerReport; report.ReportServerCredentials.NetworkCredentials = new NetworkCredential("MACHINE-NAME\\USER","Password"); Anyway, I've tried everything, short of disabling authentication altogether. Has anyone experienced authentication issues with ssrs in a hosted / virtual environment? Any help would be greatly appreciated. Thanks
January 27th, 2010 12:31am

Hi jcain,You are right. The issue is caused by the credentail passed to report server is not available. You are right too, that pass an specified credential to the report server.However, "report.ReportServerCredentials.NetworkCredentials" is a read-only property, we can't use this code to pass credential to the report server.To pass a specified credential to report server from report, we need to create custom credential class, and then pass the credentail. Below is the sample code:1.Define the credentail class: public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials { // local variable for network credential. private string _UserName; private string _PassWord; private string _DomainName; public CustomReportCredentials(string UserName, string PassWord, string DomainName) { _UserName = UserName; _PassWord = PassWord; _DomainName = DomainName; } public System.Security.Principal.WindowsIdentity ImpersonationUser { get { return null; // not use ImpersonationUser } } public System.Net.ICredentials NetworkCredentials { get { // use NetworkCredentials return new NetworkCredential(_UserName, _PassWord, _DomainName); } } public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority) { // not use FormsCredentials unless you have implements a custom autentication. authCookie = null; user = password = authority = null; return false; } } 2.Pass credential: NetworkCredential myCred = new NetworkCredential("UserName", "Password", "DomainName"); this.ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials("Administrator", "Password01!", "VJCX1855140"); Now, we should be able to call the report.If you have any more questions, please feel free to ask.Thanks,Jin Chen Jin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
January 28th, 2010 3:19am

Jin, Thanks for your reply, but I'm using WinForms. I have a WPF app hosting the 10.0 version of the report viewer in a WindowsFormsHost control. With the WinForms control, the code you sent doesn't even compile because the ReportServerCredentials property is read-only. I've used the code you provided in asp.net in the past, but need guidance on how this is done in a smart client. Thanks, Jon Cain
January 28th, 2010 10:39am

I have similar issue, we are accessing the reports server from a asp.net application hosted on a different server. I am passing the credentials explicitly, and still receiving 401:Unauthorized access. The credentials that are being passed are of an administrator account on the reporting server box. Can some one help with what needs to be done or how we can troubleshoot this ?Swapnil Kasodekar
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2010 6:32am

Hi, I am Able to Run the Report in Report Manager URL by configuring the Properties of Data Sources As Follows Creditionals Stored in SQL Server UserName::Domain\\User Password::***** And Use Windows Creditionals to Connect to Data Source I am Using NetworkCreitionals Class as Follows using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Microsoft.Reporting.WebForms; using System.Security.Principal; using System.Net; /// <summary> /// Summary description for ReportCredentials /// </summary> public class ReportCredentials : IReportServerCredentials { private string _UserName; private string _PassWord; private string _DomainName; public ReportCredentials(string UserName, string PassWord, string DomainName) { _UserName = UserName; _PassWord = PassWord; _DomainName = DomainName; } public WindowsIdentity ImpersonationUser { get { // return WindowsIdentity.GetCurrent(); return null; } } public ICredentials NetworkCredentials { get { return new NetworkCredential(_UserName, _PassWord, _DomainName); } } public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority) { // not use FormsCredentials unless you have implements a custom autentication. authCookie = null; user =_UserName; password =_PassWord ; authority = _DomainName; return false; } } try { ReportCredentials rc = new ReportCredentials("User", "****", "Domain"); //ReportViewer1; this.ReportViewer1.ServerReport.ReportServerCredentials = rc; ReportParameter rp2 = new ReportParameter("SubCategory", DropDownList2.SelectedValue); Uri uri = new Uri(@"http://localhost:8080/reportserver"); ReportViewer1.ServerReport.ReportServerUrl = uri; if (DropDownList2.SelectedIndex <= 0) { ReportViewer1.ServerReport.ReportPath = @"/Demo1/Report1"; rp2 = new ReportParameter("SubCategory", ""); } else ReportViewer1.ServerReport.ReportPath = @"/Demo1/Report2"; ReportParameter rp = new ReportParameter("Category", DropDownList1.SelectedValue); ReportParameter[] rpi = new ReportParameter[] { rp, rp2 }; ReportViewer1.ServerReport.SetParameters(rpi); ReportViewer1.ServerReport.Refresh(); } catch (Exception ex) { } I got the following Error Message : The request failed with HTTP status 401: Unauthorized. Please Help Me.
January 7th, 2011 10:51pm

Did anyone who got this error figure it out? I am struggling with the same issue.
Free Windows Admin Tool Kit Click here and download it now
January 15th, 2012 8:10pm

Hi, add the following attributes in your rsreportserver.config file. <Authentication> <AuthenticationTypes> <RSWindowsNegotiate/> <RSWindowsNTLM/> Regards, Noman Rao
May 17th, 2012 5:57am

Thnks Jin Chen. The above post is working for me. public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials { // local variable for network credential. private string _UserName; private string _PassWord; private string _DomainName; public CustomReportCredentials(string UserName, string PassWord, string DomainName) { _UserName = UserName; _PassWord = PassWord; _DomainName = DomainName; } public System.Security.Principal.WindowsIdentity ImpersonationUser { get { return null; // not use ImpersonationUser } } public System.Net.ICredentials NetworkCredentials { get { // use NetworkCredentials return new NetworkCredential(_UserName, _PassWord, _DomainName); } } public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority) { // not use FormsCredentials unless you have implements a custom autentication. authCookie = null; user = password = authority = null; return false; } } hi friends, please follow the Steps 1. Please create a new class file from your website folder or inside the App_Code folder and name the class file as CustomReportCredentials 2. Copy the above code paste in your class file. 3. Call this class from your C# code behind.(i.e : this.ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials("Administrator", "Password01!", "VJCX1855140");) 4. Then run your report from local code or from your server code(website). the report works fine. Thnks Sathish
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 6:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics