passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
Go Back  Xtreme Visual Basic Talk > > > passing SQL Server login info to Reporting Services via ASP.nET


Reply
 
Thread Tools Display Modes
  #1  
Old 07-11-2008, 09:10 AM
torpkevuk's Avatar
torpkevuk torpkevuk is offline
Contributor
 
Join Date: Oct 2003
Location: Nebraska, USA
Posts: 640
Default passing SQL Server login info to Reporting Services via ASP.nET


Hi all,

I'm having some problems getting reporting services working correctly via my asp.net page.

We have a database which has specific SQL Server login's, I need to pass the correct login information to Reporting Services so I only return the correct data. I have no control over these usernames and passwords, and I can not use some generic username/password as its payroll data and security is set up by the username.

In Reporting Services I created my report and set it to prompt for username/password. This works fine if I go directly to the report via the URL:

http://myServer/ReportServer/Pages/R...Command=Render

Where emplid is the reportname in the folder myReports

When I go there via the URL I am prompted to enter the username and password. That I can manage.. however, as my users may be going in and out of these reports all day, I dont want them to have to enter their username/password again and again.

My plan was to create an ASP.NET frontpage where I'll let them enter their username/password and I'll pass it to Reporting Services.

From there I'm kinda stuck.. I've been trying for 2 days, using different bits of code, most of which I get an error 401 on.

Here's some code I've been trying, it has a Reporting Service reportviewer called rvReporting

Code:
Try rvReporting.ServerReport.ReportServerUrl = New Uri("http://myServer/reportServer") rvReporting.PromptAreaCollapsed = True rvReporting.ServerReport.ReportPath = "/myreports/emplid" Dim dataSourceCredentials As New Microsoft.Reporting.WebForms.DataSourceCredentials() dataSourceCredentials.Name = "DEMO" ' Datasource being used by report dataSourceCredentials.UserId = "user" dataSourceCredentials.Password = "password" ' It errors out on the next line with the error message: ' Unable to automatically step into the server. Connecting to the server ' machine 'myServer' failed. rvReporting.ServerReport.SetDataSourceCredentials(New _ Microsoft.Reporting.WebForms.DataSourceCredentials(0) _ {dataSourceCredentials}) Catch ex As Exception Console.WriteLine(ex.Message) End Try

My worry is that I'm going about this the hard way..
Does anyone know a better way to get a SQL server login into RS? If not, can anyone see whats wrong with the above code?

Thanks!
Reply With Quote
  #2  
Old 07-11-2008, 10:12 AM
torpkevuk's Avatar
torpkevuk torpkevuk is offline
Contributor
 
Join Date: Oct 2003
Location: Nebraska, USA
Posts: 640
Default

I think I have it worked out.. what I was missing was some credentials to get to report service..

Heres a cobbling together of some code I've found in various places.. I did not write all this code myself but I forget where I found it..

In my main page

Code:
#Region " Objects " Private _strUsername As String = "" Private _strPassword As String = "" Private _strDataSource As String = "" Private _strReportName As String = "" Private _strReportPath As String = "" Private _strReportServerURL As String = "" #End Region #Region " Events " Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.Load If Not Page.IsPostBack Then _strUsername = "username" _strPassword = "password" _strDataSource = "datasource" _strReportServerURL = "http://myServer5/ReportServer" _strReportPath = "/myreports/" _strReportName = "emplid" rvReporting.ProcessingMode = _ Microsoft.Reporting.WebForms.ProcessingMode.Remote rvReporting.ShowCredentialPrompts = True rvReporting.ShowExportControls = True rvReporting.ServerReport.ReportServerCredentials = _ New ReportServerCredentials() rvReporting.ServerReport.ReportServerUrl = _ New Uri(_strReportServerURL) rvReporting.ServerReport.ReportPath = _ String.Concat(_strReportPath, _strReportName) Dim dataSourceCredentials As New _ Microsoft.Reporting.WebForms.DataSourceCredentials() dataSourceCredentials.Name = _strDataSource dataSourceCredentials.UserId = _strUsername dataSourceCredentials.Password = _strPassword rvReporting.ServerReport.SetDataSourceCredentials(New _ Microsoft.Reporting.WebForms.DataSourceCredentials(0) {dataSourceCredentials}) End If End Sub #End Region

And I have a class module called reportservercredentials.vb

Code:
Imports Microsoft.VisualBasic Imports Microsoft.Reporting.WebForms Imports System.Security.Principal Public NotInheritable Class ReportServerCredentials Implements IReportServerCredentials #Region " Objects " #End Region #Region " Methods " Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, _ ByRef userName As String, _ ByRef password As String, _ ByRef authority As String) _ As Boolean _ Implements IReportServerCredentials.GetFormsCredentials authCookie = Nothing userName = Nothing password = Nothing authority = Nothing 'Not using form credentials Return False End Function #End Region #Region " Properties " Public ReadOnly Property ImpersonationUser() As WindowsIdentity _ Implements IReportServerCredentials.ImpersonationUser Get 'Use the default windows user. Credentials will be provided 'by the NetworkCredentials property. Return Nothing End Get End Property Public ReadOnly Property NetworkCredentials() As _ Net.ICredentials Implements IReportServerCredentials.NetworkCredentials Get 'User name, Password & Domain Dim userName As String = "domainUser" Dim password As String = "domainPass" Dim domain As String = "Domain" Return New Net.NetworkCredential(userName, password, domain) End Get End Property #End Region End Class



Hope that saves someone else the headaches it gave me
Reply With Quote
  #3  
Old 07-19-2011, 01:25 PM
longstrd longstrd is offline
Newcomer
 
Join Date: Jul 2011
Posts: 2
Default reportviewer IReportServerCredentials Property ImpersonationUser() As WindowsIdentity

Has anyone learned how to dynamicly feed the IReportServerCredentials.
I want to pass the currently logged on Active Directory account to the Report Server.
The examples I find on the net and MSDN show how to hard code one user or use a login window.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
 
passing SQL Server login info to Reporting Services via ASP.nET
passing SQL Server login info to Reporting Services via ASP.nET
 
-->