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

边栏推荐
- [electronic circuit] how to select ADC chip
- Plato Farm有望通过Elephant Swap,进一步向外拓展生态
- Use QSS to style the form
- sql-server 数据表的简单操作
- Read and understand move2earn project - move
- Record the SQL injection vulnerability of XX company
- [JS question solution] questions 1-10 in JS of niuke.com
- Merge the same items in the same column in table
- Similarities and differences between REM and PX and EM
- Qframe class learning notes
猜你喜欢
![[typescript] in depth study of typescript functions](/img/0c/e838960c8efd6e87046d35f8942a07.png)
[typescript] in depth study of typescript functions

Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration

Wapiti是什么以及使用教程

记xx公司SQL注入漏洞

ThinkPHP6 输出二维码图片格式 解决与 Debug 的冲突

How to survive in the bear market of encryption market?

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

QT setting background image method

Fvuln-自动化web漏洞检测工具

Merge the same items in the same column in table
随机推荐
改哭了,终于解决了Cannot read properties of undefined (reading ‘parseComponent‘)
Set the background color of a cell in the table
Read and understand move2earn project - move
农村品牌建设给年轻人的一些机会
QT layout management -- Part stretch principle and sizepolicy
Masscan使用教程.
记xx公司SQL注入漏洞
Madonna "hellent" bought $1.3 million NFT boring ape, which is now considered too expensive
运动健康深入人心,MOVE PROTOCOL引领品质生活
“山东大学移动互联网开发技术教学网站建设”项目实训日志二
PHP如何生成二维码?
H5 semantic label
Summary of knowledge points related to forms and forms
ThinkPHP6 输出二维码图片格式 解决与 Debug 的冲突
Build msys2 environment with win10
如何 Pr 一个开源composer项目
DAY15:文件包含漏洞靶场手册(自用 file-include 靶场)
Sqlmap是什么以及使用方法
Idea using JDBC to connect mysql database personal detailed tutorial
Seay source code audit system