如何将基本身份验证质询转发给报表管理器URL

Thi*_*tas 24 sql-server-2008-r2 reporting-services ssrs-2008

*底部描述了环境的详细信息.

我正在尝试为报告服务构建身份验证解决方案.

应使用我们现有的costumer数据库对在线客户进行身份验证,而本地管理用户可以使用简单的基本身份验证.

我已经SSRS使用codeplex示例进行了安全扩展,我用来发出基本挑战的方法如下

public void GetUserInfo(out IIdentity userIdentity, out IntPtr userId)
{
    if (HttpContext.Current != null && HttpContext.Current.User != null)
        userIdentity = HttpContext.Current.User.Identity;
    else
    {
        HttpContext.Current.Response
            .AddHeader("WWW-Authenticate", "Basic realm=\"ReportServer\"");
        HttpContext.Current.Response.Status = "401 Unauthorized";
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.Close();
        userIdentity = new GenericIdentity("not authorized");
    }

    userId = IntPtr.Zero;
}
Run Code Online (Sandbox Code Playgroud)

这样,当没有通过该LogonUser方法的用户(即直接URL访问,出价报告部署,而不是常规用户应用程序)受到基本登录/密码弹出窗口的挑战时.为了支持这一点,我制作了如下的httpmodule

void IHttpModule.Init(HttpApplication context)
{
    context.AuthenticateRequest += CustomAuthenticateRequest;
}

void CustomAuthenticateRequest(object sender, EventArgs e)
{
    var app = sender as HttpApplication;

    if (app == null) return;

    var basicAuth = app.Context.Request.Headers["Authorization"];

    if (!string.IsNullOrEmpty(basicAuth))
    {
        var loginpass = Encoding.Default.GetString(
           Convert.FromBase64String(basicAuth.Replace("Basic ", ""))).Split(':');
        if (loginpass.Length == 2 
            && loginpass[0] == adminUser 
            && loginpass[1] == adminPass)
        {
            app.Context.User = new GenericPrincipal(
                new GenericIdentity(adminUser), null);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这在访问/ReportServerURL 时工作正常,我受到质疑,输入硬编码的管理员登录/通过并登录.

问题是访问/Reports我得到

System.Net.WebException:请求失败,HTTP状态为401:未授权

我想知道如何将登录/传递挑战一直传递给我 /Reports

我正在运行SqlServer 2012以及Reporting Services 2012,但内部工作没有改变 SSRS 2008-R2

在我的web.config

<authentication mode="None" />
<identity impersonate="false" />, and the entry for the httpmodule
Run Code Online (Sandbox Code Playgroud)

rssrvpolicy.config该代码组对我的HttpModule是FullTrust

rsreportserver.config

    <AuthenticationTypes>
        <Custom/>
    </AuthenticationTypes>, and the entry for the security extension
Run Code Online (Sandbox Code Playgroud)

我还没有SSL配置,绑定是默认的

小智 4

从错误消息来看,似乎是在渲染报表管理器的 UI 时发生身份验证错误。请转到文件夹 c:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportManager\,找到 web.config 文件,然后应用以下更改。

<authentication mode="None" />
<identity impersonate="false" />, and the entry for the httpmodule
Run Code Online (Sandbox Code Playgroud)