Thursday, March 29, 2012

Credentials in Reporting Services?

I have created several reports in SQL Server 2005 reporting services and I am viewing those reports in my C# application using a report viewer control. I want to pass the credentials for each report through my applications. I do not want to use any web service.

Is it possible?

Any help will be appreciated!!!

TIA

YOu can use the URL Parameters to pass the username and the password, look in the BOL for more information, the syntax for that is:

prefix:datasourcename=value

as the prefix is dsu (for user) or dsp (for password)

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

Thanks for your reply Jens!!!

But I am using a Report Viewer control in my application. How can I pass the username and password in this case?

|||Hi,
Hope this could help you

System.Net.CredentialCache myCache = new System.Net.CredentialCache();
myCache.Add(new Uri("http://localhost/ReportServer/ReportService.asmx"), "Basic", new System.Net.NetworkCredential("user", "pass"));

reportViewer.ShowCredentialPrompts = false;
reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = myCache;
reportViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
reportViewer.ServerReport.ReportServerUrl ="http://localhost/reportserver";
reportViewer.ServerReport.ReportPath = "/yourReportFolder/" + "yourReportName";
reportViewer.PromptAreaCollapsed = false;
reportViewer.RefreshReport();

|||

I am trying to use the example code provided for a simialr problem but the line (in VB)

reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = myCache

always shows as read only. How do I get round this please?

|||Hi ,
I think your using report viewer web control ofr asp.net. I had same problem.
Its won't work for Microsoft.Reporting.WebForms.ReportViewer.


But i hope this link could help you..

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=373983&SiteID=1

If you found the way please post back here.


Thanks & Best Regards|||

I am attempting to secure my reports with Windows Authentication, but allow users of my application to access it from the www and supply credentials through my app. My app is a .Net 2.0 Windows SmartClient, and I am using the ReportViewer control.

I tried the following suggestion:

reportViewer1.ServerReport.ReportServerUrl = new Uri(_txtServer.Text);

reportViewer1.ServerReport.ReportPath = _listBox.Items[_listBox.SelectedIndex].ToString();

reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;

CredentialCache cc = new CredentialCache();

cc.Add(new Uri("http://localhost/ReportServer/ReportService.asmx"), "Basic",

new NetworkCredential(_txtUsername.Text, _txtPassword.Text, _txtDomain.Text));

reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = cc;

reportViewer1.ShowCredentialPrompts = false;

reportViewer1.RefreshReport();

...But I still get "The request failed with HTTP status 401: Access Denied." I am able to authenticate with the web service directly when requesting a list of available reports like this:

ReportingService rService = new ReportingService();

rService.Credentials

= new NetworkCredential(_txtUsername.Text, _txtPassword.Text, _txtDomain.Text);

CatalogItem[] catalogItems;

catalogItems = rService.ListChildren("/", true);

Why can I pass windows credentials to the web service directly, but not through the reportViewer call to reporting services? Any help would be very much appreciated!

|||

Hi Glenn,

You might have got the solution for your problem, If not and/or for other developers who might visit this blog, please find the solution at following link. Actually you can get it work by setting ImpersonationUser instead of NetworkCredentials property.

http://blogs.msdn.com/bimusings/archive/2005/11/05/489423.aspx

|||

You can refer following link.

http://msdn2.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials(VS.80).aspx

|||

Hi, you can try this, might help.

I pass the datasource credential through ReportViewer. It is the acutal database login credential instead of a net work credential. So in my application, which login user has nothing to do with Windows

network login user, I am using my application's user id and password to connect to datasource.

By doing this way, I can view a report using diffirent user id/password as long as they exist in the actual database.

It works for me.

private void Form1_Load(object sender, EventArgs e)

{

.............................

Microsoft.Reporting.WinForms.DataSourceCredentials myCredential = new Microsoft.Reporting.WinForms.DataSourceCredentials();

myCredential.UserId = "myuserid";

myCredential.Password = "mypassword";

ReportDataSourceInfoCollection reportdatasourcecollection = this.reportViewer1.ServerReport.GetDataSources();

DataSourceCredentials[] myCredentials=null;

if (reportdatasourcecollection.Count > 0)

{

myCredentials = new DataSourceCredentials[reportdatasourcecollection.Count];

}

for (int iIndex = 0; iIndex < reportdatasourcecollection.Count; iIndex++)

{

ReportDataSourceInfo datasourceinfo = reportdatasourcecollection[iIndex];

myCredential.Name = datasourceinfo.Name;

myCredentials[iIndex] = myCredential;

}

this.reportViewer1.ServerReport.SetDataSourceCredentials( myCredentials );

...............................

}

|||

Hi,

I am facing the same problem.

I used ReportDataSourceInfo then it gives error that DataSource doesnt support it. Error of rsdatasource

So what should be the Connection Methods in Shared DataSource?

Nilesh

|||

Me too there's an error here.

ReportDataSourceInfoCollection reportdatasourcecollection = this.reportViewer1.ServerReport.GetDataSources();

any thoughts please?

thanks.

|||

Ishwar,

Thanks for the link. That is awesome. I got it working using the following code.

ServerReport.ReportServerCredentials.NetworkCredentials

= new NetworkCredential(properties.Username, properties.Password, properties.Domain);

No comments:

Post a Comment