我正在使用 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>
在报告服务器的web.config
文件中,我将身份验证更改为表单并模拟为假,我在报告管理器的web.config
文件中做了同样的事情。
什么都不见了。还是我是对的?
我还想我需要对 CustomSecurity Extension 术语做些什么?