我正在使用ReportViewer连接到报表服务器。 Windows身份验证效果很好..但是当我使用凭据对报表服务器进行身份验证时,我收到了错误:
请求失败,HTTP状态为401:未经授权。
我知道我需要配置报表服务器以接受这些凭据,但我实际上并不知道它是什么。是的我也经历过msdn以及堆栈问题。我是SSRS的初学者,我想将报表服务器集成到我的Web应用程序中。我在申请页面上所做的是:
protected void Page_Load(object sender, EventArgs e)
{
// if (!IsPostBack)
// {
ReportViewer1.ServerReport.ReportServerCredentials =
new MyReportServerCredentials();
// ReportViewer1.ServerReport.Refresh();
//}
}
}
[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)
{
// not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
userName = null;
password = null;
authority = null;
// Not using form credentials
return false;
}
}
在我修改的RsReportServer.config
文件中,将<authentication>
节点替换为:
<Authentication>
<AuthenticationTypes>
<Custom />
</AuthenticationTypes>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
在reportserver的web.config
文件中,我将身份验证更改为表单并模拟为false,我在reportmanager的web.config
文件中也这样做。
任何遗漏。或者我是对的?
我还猜我需要使用CustomSecurity Extension术语做什么?
答案 0 :(得分:0)
搜索
http://blogs.msdn.com/b/bimusings/archive/2005/12/05/500195.aspx
虽然这是旧的 - 但这应该是一个很好的参考,以确保它的工作清单。
答案 1 :(得分:0)
您需要在Start - &gt;的帮助下配置您的SSRS服务(位于服务器上)。所有程序 - &gt; Microsoft SQL Server 2008 - &gt;配置工具 - &gt; Reporting Services配置管理器(SSRS)