SQL Server Reporting Services 匿名登录的问题及解决方案
作者:老张一笑 发布时间:2024-01-20 04:24:05
每次访问报表都需要windows验证,这样的报表给客户确实很说不过去.
SSRS 可以匿名登录的设定步骤:
环境:
开发工具:SQL Server Business Intelligence Development Studio
数据库: SQL2008
首先确定你的Reporting Services 目录位置
默认为:C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer
打开目录会修改该目录下的3个配置文件,分别为:rsreportserver.config ,rssrvpolicy.config ,web.config
解决步骤:
1.打开rsreportserver.config
修改Configuration/Authentication/AuthenticationTypes
修改前:
<Authentication>
<AuthenticationTypes>
<RSWindowsNTLM/>
</AuthenticationTypes>
</Authentication>
修改后:
<Authentication>
<AuthenticationTypes>
<Custom/>
</AuthenticationTypes>
</Authentication>
2. 修改web.config
<!--节点:configuration/system.web/authentication -->
<!-- 修改前 -->
<authentication mode="Windows" />
<identity impersonate="true" />
<!-- 修改后 -->
<authentication mode="None" />
<identity impersonate="false" />
3. 从微软下载匿名登录的范例项目
( 下载网址 http://blog.quasarinc.com/wp-content/uploads/2012/03/Microsoft.Samples.ReportingServices.AnonymousSecurity.zip),
并且重新编译出一个新的 Microsoft.Samples.ReportingServices.AnonymousSecurity.dll 动态库,
范例为2010解决方案,其实里面用到的只是class1.cs文件,还有项目名称不能变,和我们下面配置有直接关系.
打开解决方案 将 Microsoft.ReportingServices.Interfaces.dll 的引用移除,并添加本地服务器的这个文件,位置在 ..\Reporting Services\ReportServer\bin 下, (注意别把这个dll当成万能的)
重新编译会生成 :Microsoft.Samples.ReportingServices.AnonymousSecurity.dll 将该文件放置bin目录下
4.再次修改rsreportserver.config
<!--修改节点:Configuration/Extensions/Security/Extension -->
<!-- 修改前 -->
<Security>
<Extension Name="Windows" Type="Microsoft.ReportingServices.Authorization.WindowsAuthorization, Microsoft.ReportingServices.Authorization" />
</Security>
<Authentication>
<Extension Name="Windows" Type="Microsoft.ReportingServices.Authentication.WindowsAuthentication, Microsoft.ReportingServices.Authorization" />
</Authentication>
<!-- 修改后 -->
<Security>
<Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Authorization, Microsoft.Samples.ReportingServices.AnonymousSecurity" />
</Security>
<Authentication>
<Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.AnonymousSecurity" />
</Authentication>
5. 在 rssrvpolicy.config 内新增一个节点
<!-- 要增加的节点 configuration/mscorlib/security/PolicyLevel 之下 -->
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Private_assembly"
Description="This code group grants custom code full trust. ">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll"
/>
</CodeGroup>
注意:这个Url,路径是reporting services 目录下新编译的文件,不同数据库版本,或安装目录不同,会有差异
6. 重新启动 Reporting Services
完美解决,历时半个月,这个问题终于告以段落,以后可以专心设计报表了.
以上解决方案参考于msdn上的一篇文章,做了些整理.
由于是程序员,所有手工做的事还是交给程序做,以上5个步骤,已使用程序实现:
起个名字叫:ssrs_onekey_nologin 全称:sql server report serveics 一键匿名登录配置.
主要功能,修改xml ,自己生成dll,copy至 bin目录下.
使用说明:需录入report services 目录
代码共享:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入Reporting Services目录:为空则与c盘默认sql2008");
string a = Console.ReadLine();
string basePath;
if (string.IsNullOrEmpty(a))
{
basePath = @"c:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer";
}else
{
basePath = a;
}
Console.WriteLine("Reporting Services 目录为:{0}", basePath);
Console.WriteLine("确认请按任意键...");
Console.ReadKey();
string bakPath = @"c:\SSRS_noLogin_bak\" + DateTime.Now.ToString("yyyyMMddHHmmss");
Directory.CreateDirectory(bakPath);
File.Copy(basePath + "\\rsreportserver.config", bakPath + "\\rsreportserver.config");
File.Copy(basePath + "\\web.config", bakPath + "\\web.config");
File.Copy(basePath + "\\rssrvpolicy.config", bakPath + "\\rssrvpolicy.config");
Console.WriteLine("第1步开始:");
Step1(basePath);
Console.WriteLine("第1步结束.");
Console.WriteLine("第2步开始:");
Step2(basePath);
Console.WriteLine("第2步结束.");
Console.WriteLine("第3步开始:");
Step3(basePath);
Console.WriteLine("第3步结束.");
Console.WriteLine("第4步开始:");
Step4(basePath);
Console.WriteLine("第4步结束.");
Console.WriteLine("第5步开始:");
Step5(basePath);
Console.WriteLine("第5步结束.");
Console.WriteLine("完成");
Console.ReadKey();
}
static void Step1(string basePath)
{
string file = basePath + "\\rsreportserver.config";
XmlDocument doc = new XmlDocument();
doc.Load(file); //Configuration
XmlNode xn = doc.SelectSingleNode("Configuration/Authentication/AuthenticationTypes");
XmlNode oldXn = xn.SelectSingleNode("RSWindowsNTLM");
if (oldXn == null)
{
Console.WriteLine("未找到RSWindowsNTLM,或已更改");
}
else
{
XmlNode newXn = doc.CreateElement("Custom");
xn.ReplaceChild(newXn, oldXn);
}
doc.Save(file);
}
static void Step2(string basePath)
{
XmlDocument doc = new XmlDocument();
string file = basePath + "\\web.config";
doc.Load(file);
XmlNode xn2 = doc.SelectSingleNode("configuration/system.web/authentication");
XmlElement xm2 = (XmlElement)xn2;
xm2.SetAttribute("mode", "None");
XmlNode xn3 = doc.SelectSingleNode("configuration/system.web/identity");
XmlElement xm3 = (XmlElement)xn3;
xm3.SetAttribute("impersonate", "false");
doc.Save(file);
}
static void Step3(string basePath)
{
CSharpCodeProvider objCSharpCodePrivoder = new CSharpCodeProvider();
CompilerParameters objCompilerParameters = new CompilerParameters();
objCompilerParameters.ReferencedAssemblies.Add("System.dll");
objCompilerParameters.ReferencedAssemblies.Add(basePath + @"\bin\Microsoft.ReportingServices.Interfaces.dll");
string strSourceCode = Resources.Class1;
objCompilerParameters.GenerateInMemory = false;
objCompilerParameters.OutputAssembly = "Microsoft.Samples.ReportingServices.AnonymousSecurity.dll";
CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, strSourceCode);
if (cr.Errors.HasErrors)
{
string strErrorMsg = cr.Errors.Count.ToString() + " Errors:";
for (int x = 0; x < cr.Errors.Count; x++)
{
strErrorMsg = strErrorMsg + "/r/nLine: " +
cr.Errors[x].Line.ToString() + " - " +
cr.Errors[x].ErrorText;
}
Console.WriteLine(strErrorMsg);
return;
}
File.Copy("Microsoft.Samples.ReportingServices.AnonymousSecurity.dll", basePath + @"\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll", true);
File.Delete("Microsoft.Samples.ReportingServices.AnonymousSecurity.dll");
}
static void Step4(string basePath)
{
XmlDocument doc = new XmlDocument();
string file = basePath + "\\rsreportserver.config";
doc.Load(file);
XmlNode xn2 = doc.SelectSingleNode("Configuration/Extensions/Security/Extension");
XmlElement xm2 = (XmlElement)xn2;
xm2.SetAttribute("Name", "None");
xm2.SetAttribute("Type", "Microsoft.Samples.ReportingServices.AnonymousSecurity.Authorization, Microsoft.Samples.ReportingServices.AnonymousSecurity");
XmlNode xn3 = doc.SelectSingleNode("Configuration/Extensions/Authentication/Extension");
XmlElement xm3 = (XmlElement)xn3;
xm3.SetAttribute("Name", "None");
xm3.SetAttribute("Type", "Microsoft.Samples.ReportingServices.AnonymousSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.AnonymousSecurity");
doc.Save(file);
}
static void Step5(string basePath)
{
XmlDocument doc = new XmlDocument();
string file = basePath + "\\rssrvpolicy.config";
doc.Load(file);
XmlNode xn1 = doc.SelectSingleNode("configuration/mscorlib/security/PolicyLevel/CodeGroup[@class=UnionCodeGroup]");
if (xn1 != null)
{
//已添加
}
else
{
XmlNode xn = doc.SelectSingleNode("configuration/mscorlib/security/policy/PolicyLevel");
XmlElement xe = doc.CreateElement("CodeGroup");
xe.SetAttribute("class", "UnionCodeGroup");
xe.SetAttribute("version", "1");
xe.SetAttribute("PermissionSetName", "FullTrust");
xe.SetAttribute("Name", "Private_assembly");
xe.SetAttribute("Description", "This code group grants custom code full trust.");
XmlElement xe2 = doc.CreateElement("IMembershipCondition");
xe2.SetAttribute("class", "UrlMembershipCondition");
xe2.SetAttribute("version", "1");
xe2.SetAttribute("Url", basePath + @"\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll");
xe.AppendChild(xe2);
xn.AppendChild(xe);
}
doc.Save(file);
}
}
}
ssrs onkey no login
程序共享:
下载
解决后测试页的展示:
来源:https://www.cnblogs.com/xtdhb/p/4000354.html


猜你喜欢
- 按比例获取样本数据或执行任务By:授客 QQ:1033553122开发环境win 10python 3.6.5需求已知每种分类的样本占比数,
- requests库简介requests 库是一个常用的用于 http 请求的模块,它使用 python 语言编写,可以方便的对网页进行爬取,
- 前言Python本身已有顺序表(List、Tupple)的实现,所以这里从栈开始。什么是栈想象一摞被堆起来的书,这就是栈。这堆书的特点是,最
- 在工作之余抽了点时间写了一下这个,在ie6-ie7-ff下显示位置基本都一致了。(发现demo页面用栅格线做背景,调试还真的容易得多 。热力
- 本来是只用Tenorflow的,但是因为TF有些Numpy特性并不支持,比如对数组使用列表进行切片,所以只能转战Pytorch了(pytor
- 注:本篇文章主要介绍如何在 Go 语言中定义和使用自定义类型,涉及到一定的编程基础知识和语法。如有不熟悉的地方,建议先去学习相关的基础知识。
- 检测对象中属性的存在与否可以通过几种方法来判断。 1.使用in关键字该方法可以判断对象的自有属性和继承来的属性是否存在。 var o={x:
- 我们将看到Sigls(变量名称开头处的符号)Perl 5和Perl 6之间的差别。概述让我们从Perl 5和Perl 6中的Sigils概述
- 1、要点 (1) 在C语言中没有字符串,只有字符, 在python中的字符串hello,在C
- pip install psycopg2出现错误:Looking in indexes: https://pypi.tuna.tsinghu
- 1. 问题描述对右图进行修改:请更换图形的风格请将 x 轴的数据改为-10 到 10请自行构造一个 y 值的函数将直方图上的数字,位置改到柱
- python实现监听键盘,供大家参考,具体内容如下实现服务端import picklefrom io import BytesIOimpor
- 生活中我们经常会遇到一些加密算法,今天我们就聊聊这些加密算法的Python实现。部分常用的加密方法基本都有对应的Python库,基本不再需要
- 场景:按下按钮,将左边的下拉选框内容发送给后端,后端再将返回的结果传给前端显示。按下按钮之前:按下按钮之后:代码结构这是flask默认的框架
- 引言所谓 路由 就是根据不同的 url 地址展示不同的内容或页面形象点 举个栗子??:电话的拨号界面咱们都见过都使用过你输入一串号码,就可以
- 一个正则表达式就是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式。该模式描述在查找文字主体时待匹配的一个或多个字
- 由于车票难抢,有时需要的车票已经售空,而我们需要捡漏,便可使用这个脚本。具体实现了,自动查询某一车票的余票数量,当数量产生变化时,将自动发送
- 1 配置 Python3 环境单击 工具 > 编译系统 > 新建编译系统...弹出:替换里面的内容为:{ &nbs
- 有一个群友在群里问个如何快速搭建一个搜索引擎,在搜索之后我看到了这个代码所在Git:https://github.com/asciimoo/
- 什么是 docopt?1、docopt 是一种 Python 编写的命令行执行脚本的交互语言。它是一种语言!它是一种语言!它是一种语言!2、