Reporting Service 2016 自定义身份验证

一般MSRS都是windows身份验证,在2016版本之前网上会有一些教程教你怎么去配置,但是关于2016的配置教程网上几乎没有的, 所以今天在这里分享给大家。(注:该配置方法目前只适合Reporting Service 2016,之前的版本请不要尝试

首先找到SQL SERVER的安装目录:
我是用的虚拟机所以直接安装在C盘,具体路径依你们自己的安装路径而定。

这里写图片描述

找到MSRS开头的文件夹

这里写图片描述

首先我们需要更改四个config文件:

  1. reportserver\rsreportserver.config
  2. reportserver\rssrvpolicy.config
  3. reportserver\web.config
  4. RSWebApp\Microsoft.ReportingServices.Portal.WebHost.exe.config

在rsreportserver.config里面找到节点:Authentication ,用以下内容覆盖:

<Authentication>
        <AuthenticationTypes> 
                <Custom/>
        </AuthenticationTypes>
        <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
        <RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>

再找到Security 节点用以下内容覆盖,并指定管理员账号为admin:

<Security>
<Extension Name="Forms" Type="Microsoft.Samples.ReportingServices.CustomSecurity.Authorization, Microsoft.Samples.ReportingServices.CustomSecurity" >
<Configuration>
<AdminConfiguration>
<UserName>admin</UserName>
</AdminConfiguration>
</Configuration>
</Extension>
</Security>

指定的admin账号用来配置完了之后去访问报表,如果不指定会没有权限访问报表,这里只能指定一个人。 后面我会告诉大家怎么去指定多人访问。

继续找到Authentication节点,注意这里有两个Authentication节点,要区分。用以下内容覆盖:

<Authentication>
<Extension Name="Forms" Type="Microsoft.Samples.ReportingServices.CustomSecurity.AuthenticationExtension,Microsoft.Samples.ReportingServices.CustomSecurity" />
</Authentication> 

然后找到UI节点用一下内容覆盖“下边的server要改成自己本机的server地址”

<UI>
<CustomAuthenticationUI>
<loginUrl>/Pages/UILogon.aspx</loginUrl>
<UseSSL>True</UseSSL>
</CustomAuthenticationUI>
<ReportServerUrl>http://<server>/ReportServer</ReportServerUrl>
<PageCountMode>Estimate</PageCountMode>
</UI>

用这个段代码覆盖UI之后还要继续接着添加一个UI节点:

 <UI>
    <CustomAuthenticationUI>
      <PassThroughCookies>
        <PassThroughCookie>sqlAuthCookie</PassThroughCookie>
      </PassThroughCookies>
    </CustomAuthenticationUI>
  </UI>

好了到这里就改好了一个config文件了。

然后在reportserver里面找到rssrvpolicy.config,打开找到CodeGroup节点,然后添加:

   <CodeGroup
class="UnionCodeGroup"
version="1"
Name="SecurityExtensionCodeGroup" 
Description="Code group for the sample security extension"
PermissionSetName="FullTrust">
<IMembershipCondition 
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.CustomSecurity.dll"/>
</CodeGroup>

在reportserver/ 下找到web.config,找到authentication节点,用以下内容覆盖:

<authentication mode="Forms">
        <forms loginUrl="logon.aspx" name="sqlAuthCookie" timeout="60" path="/"></forms>
</authentication> 

接着authentication节点后面添加以下内容:

<authorization> 
<deny users="?" />
</authorization> 

然后找到system.web节点,增加以下配置:

<machineKey validationKey="[YOUR KEY]" decryptionKey=""="[YOUR KEY]" validation="AES" decryption="AES" />

“[YOUR KEY]” 的生成可使用machine-key-generator 网页版的网站生成。

在 \RSWebApp\Microsoft.ReportingServices.Portal.WebHost.exe.config中的configuration下增加节点:

<system.web>
<machineKey validationKey=="[YOUR KEY]" decryptionKey=="[YOUR KEY]" validation="AES" decryption="AES" />
</system.web>

config文件的配置到这里就结束了。

现在需要一个比较重要的东西(改MSRS身份验证的安力保),在以往的版本中改身份验证在MSDN上微软给出了一个案例包里面包含了一个登录页面和三个类

这里写图片描述

这里写图片描述

在\CustomSecuritySample\Setup\CreateUserStore.sql 下面有一个sql脚本,放到数据库去执行下。

然后在bin目录里面找到~.CustomSecurity.dll和~.CustomSecurity.pdb这个两个文件,复制到
ReportServer\bin下和RSWebApp\bin下

把logon页面复制到ReportServer文件夹下。

到这里就配置完了。

最后你们可能会遇到一个问题:

这里写图片描述

是因为Reporting Server的运行账号没有访问数据库的权限造成的。

去数据库里面加下权限就可以了。

之前说了在config里面只能配置一个管理员账号,那如果想让别的人也要有权限看报表的话,就得去改微软给的案例里面的一个名为“Authorization”的类,里面有很多名为CheckAccess的方法:

这里写图片描述

仔细观察这个方法里面有一个判断:

这里写图片描述

判断username等于m_adminUserName,就是这个地方,由于我是在所有用户进入报表之后再对用户进行权限分配的,所以这个地方我的改法是“username=username” 改完之后所有用户都有查看报表的权限了。当然这个地方你们可以根据自己的需要自行更改。

更多文章请扫码关注公众号,有问题的小伙伴也可以在公众号上提出哦。

这里写图片描述

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值