我使用ReportViewer控件从部署在IIS7上的VS2010 ASP.NET MVC 2 Web应用程序访问SSRS 2008报告,设置如下:
由于我需要使用单独的凭据来访问SSRS报告,所以我实现了IReportServerCredentials,如下所示:
http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials(v=vs.100).aspx
我遇到的问题是,它总是转到IReportServerCredentials.ImpersonationUser,而不是IReportServerCredentials.NetworkCredentials,因为我要从web.config检索所需的凭据。
也许我错过了一些简单的东西,但我尝试了不同的组合这些设置,没有运气。任何关于我如何获得这项工作的建议都将是非常感谢的!
我的代码:
[Serializable]
public sealed class MyReportServerCredentials :
IReportServerCredentials
{
public WindowsIdentity ImpersonationUser
{
get
{
// Use the default Windows user. Credentials will be
// provided by the NetworkCredentials property.
return null;
}
}
public ICredentials NetworkCredentials
{
get
{
// Read the user information from the Web.config file.
// By reading the information on demand instead of
// storing it, the credentials will not be stored in
// session, reducing the vulnerable surface area to the
// Web.config file, which can be secured with an ACL.
// User name
string userName =
ConfigurationManager.AppSettings
["MyReportViewerUser"];
if (string.IsNullOrEmpty(userName))
throw new Exception(
"Missing user name from web.config file");
// Password
string password =
ConfigurationManager.AppSettings
["MyReportViewerPassword"];
if (string.IsNullOrEmpty(password))
throw new Exception(
"Missing password from web.config file");
// Domain
string domain =
ConfigurationManager.AppSettings
["MyReportViewerDomain"];
if (string.IsNullOrEmpty(domain))
throw new Exception(
"Missing domain from web.config file");
return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie,
out string userName, out string password,
out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
// Not using form credentials
return false;
}
}
this.MyReportView.ServerReport.ReportServerCredentials = new MyReportServerCredentials();谢谢
发布于 2012-03-20 06:03:01
我在我需要的每个报告页面上实现了同一个类,并且它正常工作。
检查您的web.config文件。
我有:
<configuration>
<system.web>
<authentication mode="Windows"/>
</configuration>
</system.web>是。身份验证模式"Windows“。
但是,我也使用过表单身份验证。
所以我认为这更多的是一个权限问题。
检查这篇文章:
UAC 7 (Proffesional) 64位和SSRS 2008 R2 (10.50.1617) 64位
也是这个职位:
Reporting 2008:询问用户名和密码
https://stackoverflow.com/questions/9763282
复制相似问题