我在报告服务器上运行了SSRS 2008 R2报告。当我使用报表管理器或Web服务URL访问报表时,它可以正常工作。
http://mycomputer/ReportServer
和
http://mycomputer/Reports
当我将ReportViewer添加到WebForms网站并将其指向
时http://mycomputer/reportserver
使用我的报告的报告路径,在使用VS.net的Web服务器运行网站时,它会给我一个访问被拒绝错误。
授予用户'mycomputer \ myusername'的权限不足以执行此操作。 (rsAccessDenied)
以下是我在aspx页面中使用的确切代码。
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt" Width="712px">
<ServerReport ReportPath="/MyReports" ReportServerUrl="http://mycomputer/reportserver" />
</rsweb:ReportViewer>
mycomputer \ myusername是计算机上的管理员。我还在ReportManager中将其添加为管理员。
我在管理员模式下使用IE运行它。
还有什么可能导致访问被拒绝的问题?
我读过其他有问题的人,但其中大部分都不适用于2008R2,所以我无法弄清楚如何尝试他们所做的事情。没有IIS可供配置,也没有IUSR可以访问报告。
SSRS日志只显示相同的错误消息,而没有任何其他信息。
答案 0 :(得分:2)
创建实现IReportServerCredentials的实例类应解决问题。添加以下类并按如下方式调用它:
ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("username", "pwd", "domain");
/// <summary>
/// Local implementation of IReportServerCredentials
/// </summary>
public class ReportServerCredentials : IReportServerCredentials
{
private string _userName;
private string _password;
private string _domain;
public ReportServerCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public WindowsIdentity ImpersonationUser
{
get
{
// Use default identity.
return null;
}
}
public ICredentials NetworkCredentials
{
get
{
// Use default identity.
return new NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// Do not use forms credentials to authenticate.
authCookie = null;
user = password = authority = null;
return false;
}
}
感谢Phil Clewes:link