SQL Reports windows authentication
I created a SQL report using windows credentials When i try to access the same report from my web application, the web application sends the impersonate user name password, instead i want to send the web application logged in use account to the report. How do i achieve this
July 1st, 2011 5:42am

Are you using ReportViewer control and accessing Server Report? If yes, then check : http://msdn.microsoft.com/en-us/library/aa983458.aspx For more detailed approach, see: http://blogs.msdn.com/b/brianhartman/archive/2008/11/21/custom-credentials-in-the-report-viewer.aspx Hope this helps..Chaitanya( Twitter | Blogs ) Any documentation bug? Tell us about it at Connect. Please feel free to add any community comments in any of the MSDN/technet articles. This posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2011 6:31am

Thanks for th reply I have set authentication mode as windows in my web.config file My web.config has impersonate user set to true, where i have some user detail for which reports cannot run. But my web application logged in user can run the reports i have set rights to him in my database ans sql server. My rdl file is created with windows authentication I am using reportviewer control, at run time i am setting the report server url and report path and even the parameters what happens is my impersonate user goes as credential for reports, so my reports fails for the user. How do i pass logged in user details The link what you have suggested says, by default asp.net thread user creadential will be set. Below is the piece of code what i have done, Am i missing some thing here String ReportURL = "<http://server25/reportserver>"; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ReportURL); ReportViewer1.ProcessingMode = ProcessingMode.Remote; ReportViewer1.ShowCredentialPrompts = false; ReportViewer1.ServerReport.ReportPath = string.Concat("/", "NTReport/BatchSummary"); ReportViewer1.Visible = true;
July 1st, 2011 9:38am

Any replies Moderators or Experts in Repots kindly help me out, i am struggling for the past 2 daysRaamakarthikeyan
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2011 11:10am

Try creating a class of this form: using System.Security.Principal; using System.Net; namespace ReportViewerCredentials { public interface IReportServerCredentials { WindowsIdentity ImpersonationUser { get; } ICredentials NetworkCredentials { get; } bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority); } class MyCredentials : IReportServerCredentials { private string m_userName; private string m_password; public MyCredentials(string userName, string password) { m_userName = userName; m_password = password; } public WindowsIdentity ImpersonationUser { get { return null; } } public ICredentials NetworkCredentials { get { return new NetworkCredential(m_userName, m_password); } } public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) { authCookie = null; userName = null; password = null; authority = null; return true; } } } Then refer the above class, and call the below code snippet to set the credentials to the default one: System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials; MyCredentials rsCredentials = reportViewer1.ServerReport.ReportServerCredentials rsCredentials.NetworkCredentials = credentials; The above code snippet would pass the logged in credentials. You can also refer: http://praveenbattula.blogspot.com/2010/01/report-viewer-control-authentication_16.html, this has similar steps to achieve this in a web application. Chaitanya( Twitter | Blogs ) Any documentation bug? Tell us about it at Connect. Please feel free to add any community comments in any of the MSDN/technet articles. This posting is provided "AS IS" with no warranties, and confers no rights.
July 1st, 2011 12:00pm

Chaitanya System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials; MyCredentials rsCredentials = reportViewer1.ServerReport.ReportServerCredentials rsCredentials.NetworkCredentials = credentials; The snippet that you have given gives me build error. Cannot implicitly convert type 'Microsoft.Reporting.WebForms.IReportServerCredentials' to 'PSG.Report.Viewer.MyCredentials'. An explicit conversion exists (are you missing a cast?) Property or indexer 'Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials' cannot be assigned to --- read only Raamakarthikeyan
Free Windows Admin Tool Kit Click here and download it now
July 5th, 2011 3:27am

Check this blog post, http://social.msdn.microsoft.com/forums/en-US/vsreportcontrols/thread/5aa7eee7-d4a7-427a-ab8d-7a3d4d4f0bf3/, and this has code which can fix your problem. This is : ReportViewerCredentials rpCredentials = new ReportViewerCredentials(ConfigurationManager.AppSettings["ReportUser"], ConfigurationManager.AppSettings["ReportPassword"], ConfigurationManager.AppSettings["ReportDomain"]); ReportViewer1.ServerReport.ReportServerCredentials = rpCredentials; Here ReportViewerCredentials is the class that we created. You might need to change this as per your code snippet. This could be: MyCredentials rpCredentials = new MyCredentials(ConfigurationManager.AppSettings["ReportUser"], ConfigurationManager.AppSettings["ReportPassword"], ConfigurationManager.AppSettings["ReportDomain"]); ReportViewer1.ServerReport.ReportServerCredentials = rpCredentials; Hope this helps.. Chaitanya( Twitter | Blogs ) Any documentation bug? Tell us about it at Connect. Please feel free to add any community comments in any of the MSDN/technet articles. This posting is provided "AS IS" with no warranties, and confers no rights. The next CTP for SQL Server Code Name "Denali" is coming soon. Sign up now to be notified of the next CTP release.
July 5th, 2011 4:28am

Chaitanya, The above case what ever you have said will work, but my actual problem is i need to set report server credentials with the user who has logged in, which i cannot put it in appsettings, because i wont be knowing who will be logging in. If i put it in appsetting always the reportserver credential is going to be set with the configured user credential. I want to set the logged in user credential. I run my web application in windows authentication. Raamakarthikeyan
Free Windows Admin Tool Kit Click here and download it now
July 5th, 2011 4:52am

Looks like http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials.networkcredentials.aspx, is a readonly property, and that might be the reason why we are unable to assign the Credentials. Can you file a bug through Connect.microsoft.com? I can do some research on any other ways to implement this...Chaitanya( Twitter | Blogs ) Any documentation bug? Tell us about it at Connect. Please feel free to add any community comments in any of the MSDN/technet articles. This posting is provided "AS IS" with no warranties, and confers no rights. The next CTP for SQL Server Code Name "Denali" is coming soon. Sign up now to be notified of the next CTP release.
July 5th, 2011 8:58am

Chaitanya I do have some other doubts in rdl file creation When i create a rdl file i am forced to give a static server name and dbname and type of credential. Once i am done with my report creation before deploying i go and change the connection string as expression ="datasource="&Parameters!ServerName.Value&";initial catalog=&Parameters!Database.Value The same way i want to change the credential type also at run time. How do i achieve this? I got some details from the below link http://blogs.msdn.com/b/bimusings/archive/2006/07/20/673051.aspx which i got through msdn forum. The problem here is, to achieve this i am been asked to create an unattended account in the report server which my client doen not allow, since because he needs to update the login detail in the newly created account as and when there is a change the windows logon details. Do you have any other suggestionsRaamakarthikeyan
Free Windows Admin Tool Kit Click here and download it now
July 5th, 2011 9:25am

Passing on the UserName and Password, as you did using an expression isn't possible. This was rightly explained in the above blog post, which says: "This gets a bit tricky. First, when you initially build your data source you must provide credentials to access the data source (in the "Credentials" tab) so that you can run/test your queries and get a list of fields populated in your dataset. Then (as the notes above mention), when your report is "ready", you go back in and change the connection string to an expression. However, you'll find that once you publish the report, it continues to use the *original* set of credentials you set in the credentials tab...not the new "dynamic" ones provided in your parameters. The trick here is that after you publish, you must remember to go to the the Data Sources tab in Report Manager and select the "Credentials are not required” option. It's only at that point that the username/password that you originally set for the report is ignored and SSRS starts using the dynamic ones." You can probably try to script some scripts to change the Credentials once you are done with building your RDL files. The Script Samples, http://msftrsprodsamples.codeplex.com/wikipage?title=SS2008%21Script%20Samples%20%28Reporting%20Services%29&referringTitle=Home, would give you an idea of how to use SSRS WMI Providers, and customize some of the SSRS Administration tasks. Note: Suggest you to start a new thread so that the topic title is not misleading, and we might get a few more suggestions from other SSRS Experts. Please mark this as answered. Thanks Chaitanya( Twitter | Blogs ) Any documentation bug? Tell us about it at Connect. Please feel free to add any community comments in any of the MSDN/technet articles. This posting is provided "AS IS" with no warranties, and confers no rights. The next CTP for SQL Server Code Name "Denali" is coming soon. Sign up now to be notified of the next CTP release.
July 6th, 2011 12:59am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics