September 24, 2008 at 6:38 am
I need help with running a reporting services report from an asp page.
It is working fine when I run the report locally, but once i upload it as an external site, I get a 401, authenthication error.
I tried setting the credentials by doing so:
ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new System.Net.NetworkCredential(
"user", "pass", "domain");
But NetworkCredentials is READONLY in ASP, different to winforms...
Please somebody help me.
September 25, 2008 at 8:25 am
giontech (9/24/2008)
I need help with running a reporting services report from an asp page.It is working fine when I run the report locally, but once i upload it as an external site, I get a 401, authenthication error.
I tried setting the credentials by doing so:
ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new System.Net.NetworkCredential(
"user", "pass", "domain");
But NetworkCredentials is READONLY in ASP, different to winforms...
Please somebody help me.
I got the same error a year ago. Let me make sure I understand the situation. You have your report(s) stored on the reporting server and you made a service account in order to grab the reports from that server from your classic asp code?
Try this code out (This is asp.net code so you may have to convert this, not sure if your are using classic asp)
I usually don't like just giving people code, but this was not very well documented by MS on how to do this.... IMAGINE THAT... Please if you have any questions let me know and I'll try to help you out as much as I can.
'CREATE a Class for CustomReportCredentials
Public Class CustomReportCredentials
Implements Microsoft.Reporting.WebForms.IReportServerCredentials
' local variable for network credential
Private strUserName As String
Private strPassWord As String
Private strDomainName As String
Public Sub New(ByVal UserName As String, ByVal PassWord As String, ByVal DomainName As String)
strUserName = UserName
strPassWord = PassWord
strDomainName = DomainName
End Sub
Public ReadOnly Property ImpersonationUser() As System.Security.Principal.WindowsIdentity Implements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser
Get
' not use ImpersonationUser
Return Nothing
End Get
End Property
Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials
Get
' use NetworkCredentials
Return New NetworkCredential(strUserName, strPassWord, strDomainName)
End Get
End Property
Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef userName As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials
' not use FormsCredentials unless you have implements a custom autentication.
authCookie = Nothing
password = authority = Nothing
Return False
End Function
End Class
---Use this code where you need to pass to the reporting server...
Dim mycred As IReportServerCredentials = New CustomReportCredentials(SSRSUserId, SSRSPassword, SSRSDomain)
'Set Processing Mode (Grabbing Report from Reporting Server)
ReportViewer1.ProcessingMode = ProcessingMode.Remote
'Set the Report Server, Path, ServerCredentials
'Getting RptServerURL, RptPath, and Credentials from Config
With ReportViewer1.ServerReport
.ReportServerUrl = 'RptServerURL'
.ReportPath = 'RptPath'
.ReportServerCredentials = mycred
End With
June 18, 2010 at 8:17 am
Been looking for this answer. Worked a treat 🙂
March 14, 2011 at 4:05 am
Thanks for posting the code for this.
I've implemented exactly the same thing, but when I load the page with the ReportViewer control, the loading panel comes up but no data appears in the report. I've not found an answer on the web to why this could be happening.
Has anyone any idea what this could be?
Thank you!!
March 14, 2011 at 7:19 am
rachel.clements (3/14/2011)
Thanks for posting the code for this.I've implemented exactly the same thing, but when I load the page with the ReportViewer control, the loading panel comes up but no data appears in the report. I've not found an answer on the web to why this could be happening.
Has anyone any idea what this could be?
Thank you!!
Are you using update panels?
Are you using a Stored Procedure to return data?
Any required parameters?
When you run your SP or Select statement in native SQL, do you get results?
It could be a multitude of issues, beyond the scope of the code that I posted.
Is it a requirement that you pull the report (.rdl) from the reporting server? Could you possibly create the report and store the .rdlc within your project?
March 14, 2011 at 10:50 am
Thanks for your reply, I didn't have a If not Page.IsPost which was preventing it from loading.
http://blogs.msdn.com/b/brianhartman/archive/2010/03/21/reports-never-stop-loading-with-vs-2010.aspx
March 14, 2011 at 12:18 pm
rachel.clements (3/14/2011)
Awesome Rachel! I will keep that in mind when migrating to VS 2010 and going to 4.0 framework. Good work!
December 29, 2011 at 12:46 pm
Mr. acatalano5! This was the answer to the last three days of my miserable life! I have searched and searched for this information and now my application can display an SSRS report running on a remote SSRS server. :w00t:
December 29, 2011 at 1:54 pm
Have a Happy New Year! I am so glad this solution worked for you guys!
March 27, 2012 at 7:30 pm
Hi there
I am also running into this problem but I am having an issue with using the ReportViewer control.
Visual Studio 2010 SP1
.Net 3.5
SSRS 2008 R2
Getting the error:
The request failed with HTTP status 401: Unauthorized.
The web.config has settings:
<authentication mode="Windows" />
<identity impersonate="true" />
What I am trying to do is use the credentials of the user who is using the web site and not use a hard coded user id and password. I have set the credentials to WindowsIdentity.GetCurrent().
I hope some one might help
Regards
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply