2

我正在使用 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 术语做些什么?

4

2 回答 2

0

正在搜索

http://blogs.msdn.com/b/bimusings/archive/2005/12/05/500195.aspx

虽然这是旧的 - 这应该是一个很好的参考清单,以使其工作。

于 2012-09-27T14:58:45.253 回答
0

您必须在开始 -> 所有程序 -> Microsoft SQL server 2008 -> 配置工具 -> Reporting Services 配置管理器 (SSRS) 的帮助下配置您的 SSRS 服务(位于服务器上)

http://msdn.microsoft.com/en-us/library/ms156305.aspx

于 2013-01-10T06:45:04.840 回答