Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Report Viewer Error :: The request failed with HTTP status 401: Unauthorized. Expand / Collapse
Author
Message
Posted Wednesday, November 26, 2008 1:49 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 14, 2013 9:31 AM
Points: 112, Visits: 168
I'm trying to call a report viewer from a page prompting for three parameters:
1. Dropdown list value
2. Start Date
3. End Date

The request failed with HTTP status 401: Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Source Error:


Line 51:
Line 52: // Set the report parameters for the report
Line 53: ReportViewer1.ServerReport.SetParameters(



***********************
***********************

The class I'm using is:

[Serializable()]
public sealed class MyReportServerCredentials2 : IReportServerCredentials
{
#region IReportServerCredentials Members

private string credUser;
private string credPassword;
private string credDomain;

public MyReportServerCredentials2(string user, string password, string domain)
{
credUser = user;
credPassword = password;
credDomain = domain;
}
public WindowsIdentity ImpersonationUser
{

//Use the default windows user. Credentials will be
//provided by the NetworkCredentials property.
get { return null; }

}
public ICredentials NetworkCredentials
{
get
{

//Read the user information from the web.config file.
//By reading the information on demand instead of storing
//it, the credentials will not be stored in session,
//reducing the vulnerable surface area to the web.config
//file, which can be secured with an ACL.

//User name
string userName = credUser;

//Dim userName As String = _
// ConfigurationManager.AppSettings("MyReportViewerUser")

if ((string.IsNullOrEmpty(userName)))
{
throw new Exception("Missing user name from web.config file");
}

//Password
string password = credPassword;

//Dim password As String = _
// ConfigurationManager.AppSettings("MyReportViewerPassword")

if ((string.IsNullOrEmpty(password)))
{
throw new Exception("Missing password from web.config file");
}

//Domain
string domain = credDomain;

//Dim domain As String = _
// ConfigurationManager.AppSettings("MyReportViewerDomain")

if ((string.IsNullOrEmpty(domain)))
{
throw new Exception("Missing domain from web.config file");
}

return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{

authCookie = null;
userName = null;
password = null;
authority = null;

//Not using form credentials
return false;

}
#endregion
}


********************
********************
The above class is called in my code behind page_load as:

if (!Page.IsPostBack)
{
// Set the processing mode for the ReportViewer to Remote
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerCredentials2("user", "password", "domain");


// Set the report server URL and report path
serverReport.ReportServerUrl = new Uri("http://Mydomain/reportserver");
serverReport.ReportPath = "/correctfolder";

// Create the sales order number report parameter
ReportParameter rpDivision = new ReportParameter();
rpDivision.Name = "Division";
string rqsDivision = Request.QueryString["Division"];
rpDivision.Values.Add(rqsDivision);

// Set the report parameters for the report
ReportViewer1.ServerReport.SetParameters(
new ReportParameter[] { rpDivision });
}



*******************
*******************


In my web.config I have:









<identity impersonate="true" userName="registry:HKLM\SOFTWARE\...\ASPNET_SETREG,userName"

password="registry:HKLM\SOFTWARE\...\ASPNET_SETREG,password" />


*******************
*******************
I've tried several different solutions, and can't get past this 401 error.
Post #609422
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse