当前位置:网站首页>Reporting Service 2016 自定义身份验证
Reporting Service 2016 自定义身份验证
2022-07-29 05:20:00 【Denny辉】
一般MSRS都是windows身份验证,在2016版本之前网上会有一些教程教你怎么去配置,但是关于2016的配置教程网上几乎没有的, 所以今天在这里分享给大家。(注:该配置方法目前只适合Reporting Service 2016,之前的版本请不要尝试)
首先找到SQL SERVER的安装目录:
我是用的虚拟机所以直接安装在C盘,具体路径依你们自己的安装路径而定。

找到MSRS开头的文件夹

首先我们需要更改四个config文件:
- reportserver\rsreportserver.config
- reportserver\rssrvpolicy.config
- reportserver\web.config
- 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” 改完之后所有用户都有查看报表的权限了。当然这个地方你们可以根据自己的需要自行更改。
更多文章请扫码关注公众号,有问题的小伙伴也可以在公众号上提出哦。

边栏推荐
- Shanzhai coin Shib has a US $548.6 million stake in eth whale's portfolio - traders should be on guard
- 机器学习让文字识别更简单:Kotlin+MVVM+华为ML Kit
- ThinkPHP6 输出二维码图片格式 解决与 Debug 的冲突
- “山东大学移动互联网开发技术教学网站建设”项目实训日志四
- 完全去中心化的编程模式,不需要服务器,也不需要ip,就像一张漫无目的的网络、四处延伸
- DAY4:MySQL 数据库的建立及简单实用
- 运动健康深入人心,MOVE PROTOCOL引领品质生活
- Seay source code audit system
- Fantom (FTM) 价格将在未来几天飙升 20%
- 裸金属云FASS高性能弹性块存储解决方案
猜你喜欢

Read and understand move2earn project - move

WIN10 编译ffmpeg(包含ffplay)

Crypto giants all in metauniverse, and platofarm may break through

DAO赛道异军突起,M-DAO的优势在哪里?

Qt设置背景图片方法

The bear market is slow, and bit.store provides stable stacking products to help you get through the bull and bear market

CMD window under Windows connects to MySQL and operates the table

DAY13:文件上传漏洞

Wapiti是什么以及使用教程

DAY15:文件包含漏洞靶场手册(自用 file-include 靶场)
随机推荐
SQL修复重复数据
Dao race track is booming. What are the advantages of m-dao?
华为2020校招笔试编程题 看这篇就够了(上)
“山东大学移动互联网开发技术教学网站建设”项目实训日志三
QFrame类学习笔记
Madonna "hellent" bought $1.3 million NFT boring ape, which is now considered too expensive
The Platonic metauniverse advocated by musk has long been verified by platofarm
DAY6:利用 PHP 编写文件上传页面
Fantom (FTM) 在 FOMC会议之前飙升 45%
win10+opencv3.2+vs2015配置
Seay源代码审计系统
性能对比|FASS iSCSI vs NVMe/TCP
Print out all prime numbers between 1-100
北京宝德&TaoCloud共建信创之路
Okaleido tiger logged into binance NFT on July 27, and has achieved good results in the first round
Go|gin quickly use swagger
DAY15(DAY16拓展):文件包含漏洞
超简单集成HMS ML Kit 人脸检测实现可爱贴纸
如何 Pr 一个开源composer项目
DeFi 2.0的LaaS协议,重振DeFi赛道发展的关键