asp.net - WebException using reportviewer -
i'm trying connect reportingservices through asp.net web reportviewer control:
rvcontract.processingmode = microsoft.reporting.webforms.processingmode.remote; rvcontract.serverreport.reportservercredentials = new reportservercredentials("myusername", "mynetworkpassword", "domain"); rvcontract.serverreport.reportserverurl = new uri(reportconfiguration.reportserverurl); string rptpath = reportconfiguration.rootpath; if (!rptpath.endswith("/")) { rptpath += "/"; } rvcontract.serverreport.reportpath = rptpath + "adminreports/contract"; list<reportparameter> reportparams = new list<reportparameter>(); if (mkosession.accountid.hasvalue) { reportparameter accountid = new reportparameter("accountid", mkosession.accountid.value.tostring()); } rvcontract.serverreport.setparameters(reportparams); rvcontract.showparameterprompts = false; rvcontract.showzoomcontrol = false; rvcontract.serverreport.refresh(); rvcontract.databind();
the implementation of credentials looks this:
public class reportservercredentials : ireportservercredentials { private string _username; private string _password; private string _domain; public reportservercredentials(string username, string password, string domain) { _username = username; _password = password; _domain = domain; } public windowsidentity impersonationuser { { // use default identity. return null; } } public icredentials networkcredentials { { // use default identity. return new networkcredential(_username, _password, _domain); } } public bool getformscredentials(out cookie authcookie, out string user, out string password, out string authority) { // not use forms credentials authenticate. authcookie = null; user = null; password = null; authority = null; return false; } }
just hard-coding credentials while testing. before check-in, we'll have create domain account this.
i can hit both reportservice2005.asmx , reportexecution2005.asmx (which reportserverurl becomes) no problem through browser.
when setparameters call, webexception. looking @ headers in response within exception:
{rsnotauthenticated: true rsauthenticationheader: .aspxformsauth content-length: 206 cache-control: private content-type: text/html; charset=utf-8 date: tue, 24 sep 2013 16:15:08 gmt location: /reportserver/logon.aspx?returnurl=%2freportserver%2freportexecution2005.asmx server: microsoft-httpapi/2.0 x-aspnet-version: 2.0.50727
}
which seems if it's telling me haven't logged in. if that's case, how exact same credentials allow me see web services through browser?
btw, did set breakpoints in each of methods in reportservercredentials implementation , saw each breakpoint hit. not sure that's telling us, networkcredentials interface returned network credentials fine.
i think might've stumbled it. in case else having similar troubles.
first, poked around , found reporting services web.config on server. saw using authenticaion mode = forms.
so, implemented getformscredentials return true , pass generic username. got username out of users table in reportserver database.
no longer getting webexception, reportviewer isn't displaying either. so, not out of woods yet, seems closer.
fwiw, think remember saying had weird custom forms authentication on our db server. so, happens upon this, ymmv. of predates me, i'm not sure how check out.
Comments
Post a Comment