J4N
J4N

Reputation: 20697

User auth problem when trying to access to the SQL Server Reporting service's webservice

I've a SSRS(2008 standard, not R2), so I'm using ReportExecution2005.asmx and ReportService2005.asmx to run them.

We developed an application which can connect to the SSRS through a webservice. It worked well on our test server, but now I'm trying to configure a new server on a virtual machine, and no way, everytimes the application tries to connect to the SSRS webservice, I get a 401 unautorized.

it's very strange, because if I only put the .asmx url in firefox on the client workstation, it prompts me for username-password, I enter it and I get the wsdl definition, so I think that the access is correct.

Here is my code:

    public ReportGateway()
    {
        _rs = new ReportingService2005 { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"])  };
        _rs.Url = "http://MyMachine:80/ReportServer/ReportService2005.asmx";//?? I saw when I was debugging that it wasn't reading the value in the app.config, but keeping the url of the reference when I created it, so for my test of the moment, I hard-setted it
        _rsExec = new ReportExecution2005.ReportExecutionService { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) };
        _rsExec.Url = "http://MyMachine:80/ReportServer/ReportExecution2005.asmx";//Same
        GenerateReportList();
    }
    [MethodImpl(MethodImplOptions.Synchronized)]
    private void GenerateReportList()
    {
        try
        {
            Dictionary<String, SRSSReport> reports = new Dictionary<String, SRSSReport>();
            foreach (var children in _rs.ListChildren("/", true))
            {
                if (children.Type == ItemTypeEnum.Report)
                {
                    SRSSReport report = new SRSSReport {Name = children.Name, Path = children.Path};
                    ReportParameter[] parameters = _rs.GetReportParameters(children.Path, null, false, null, null);
                    foreach (ReportParameter parameter in parameters)
                        report.Parameters.Add(new SRSSReportParameter {Name = parameter.Name, Type = _typeConverstion[parameter.Type]});
                    reports.Add(report.Path, report);
                }
            }
            lock (_lockObject)
            {
                _reports = reports;
            }
        }catch(Exception ex)
        {
            _reports = new Dictionary<string, SRSSReport>();
            Logger.Instance.Error("Error when contacting the reporting server", ex);
        }
    }

I'm completly desperate for now, I've looked for a solution during days, and I don't know what I can have done wrong.

Do you have an idea/solution/... to help me?

Thank you very much, any help would be really appreciated.

Upvotes: 0

Views: 4729

Answers (1)

ErikE
ErikE

Reputation: 50191

You need to call the LogonUser method of SSRS web services. From Authentication in Reporting Services:

The primary way to authenticate against a report server in Reporting Services is the LogonUser method. This member of the Reporting Services Web service can be used to pass user credentials to a report server for validation. Your underlying security extension implements IAuthenticationExtension.LogonUser which contains your custom authentication code. In the Forms Authentication sample, LogonUser, which performs an authentication check against the supplied credentials and a custom user store in a database.

In case you need to check for any IIS problems check out Troubleshooting HTTP 401 errors in IIS.

Also, you should know that when connecting to an IIS site that expects you to use authentication, you will first get a 401 Unauthorized error to indicate that you need to present credentials. Web browsers swallow this silently and then either supply current Windows credentials (e.g., IE) or prompt you for credentials (e.g., Firefox, unless you've tweaked it somehow to present them automatically).

Upvotes: 1

Related Questions