I was redirected here from StackOverflow...

I have set up a web based report viewer using the SSRS reportviewer control (sql server 2008 r2) including the ability to specify credentials.

When I comment out the bit that sets the credentials and run the web page the report is displayed.

When I set the credentials to something invalid I get "The request failed with HTTP status 401: Unauthorized."

When I set the credentials to something valid I get "Log on failed. Ensure the user name and password are correct. (rsLogonFailed)"

For the valid credentials I have gone into the SQL Server Reporting Services web page and set up the user security in Site Settings and also set up the secrity in the Folder Settings as discussed in this link HowTo Install SQL Server 2008 R2. I have verified that the users have db_owner and RSExecRole in SQL server and that goes for both the ReportServer database and the source data database. Also I have added the users to the SQLServerReportServerUser... security group.

The code that calls the report server control is as follows, the error occurs on the last line

ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(@"http://MyComputer/reportserver/");
ReportViewer1.ServerReport.ReportPath = @"/MyReport";
CustomReportCredentials creds = new CustomReportCredentials("ReportViewer", "thepassword", "Mycomputer");
ReportViewer1.ServerReport.ReportServerCredentials = creds;
ReportViewer1.AsyncRendering = false;
ReportParameterInfoCollection parameters = ReportViewer1.ServerReport.GetParameters();

I implemented CustomReportCredentials as

public class CustomReportCredentials : IReportServerCredentials {
    // local variable for network credential.
    private string _UserName;
    private string _PassWord;
    private string _DomainName;
    private Cookie _authCookie;

    public CustomReportCredentials(string UserName, string PassWord, string DomainName) {
        _UserName = UserName;
        _PassWord = PassWord;
        _DomainName = DomainName;

    public CustomReportCredentials(Cookie authCookie) {
        _authCookie = authCookie;

    public WindowsIdentity ImpersonationUser {
        get {
            return null;  // not using ImpersonationUser

    public 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) {
        authCookie = null;
        user = password = authority = null;
        return false;


What am I missing? Thanks

  • the rsLogonFailed turned out to be caused by a problem with my GetFormsCredentials method, which I have fixed above. Then I added my report user to the source database security - users with db_readdate role and now it all works – nuander Jan 29 '13 at 0:37
  • Hey @nuander, good to hear you solved your problem! It would be great if you could write up an answer, so others with the same problem can spot/find it easily. – Jeroen Feb 13 '13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.