Friday, March 30, 2012

ReportViewer control Impersonate User

I need to impersonate to allow my asp.net ReportViewer control to load
reports from my SQL 2005 reporting server.
I have two ways of doing that and I was wondering which way was best
practice (or if there is any better way):
--
Method1: impersonate in in web.config
identity impersonate="true" userName="domain\username" password="password"
--
Method2: override IReportServerCredentials
...
if (!Page.IsPostBack)
rv1.ServerReport.ReportServerCredentials = new
MyReportServerCredentials();
...
[Serializable]
public sealed class MyReportServerCredentials : IReportServerCredentials
...
return new NetworkCredential(...)
(above explained excellantly in
http://msdn2.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials(VS.80).aspx)
Thank you!Hello Dev,
I suggest you use the second method. If you impersonate in the web.config
file, the whole application will effected and since you hardcode your
credential information in the web.config, it may have some security issue.
If you use the IReportCredentials and programmatically specify the
credential, it only use on the page which include the ReportViewer Control
which is more secure.
Hope this helps.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================(This posting is provided "AS IS", with no warranties, and confers no
rights.)|||Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment