iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >SQL Server Reporting Services 匿名登录的问题及解决方案
  • 721
分享到

SQL Server Reporting Services 匿名登录的问题及解决方案

2024-04-02 19:04:59 721人浏览 安东尼
摘要

每次访问报表都需要windows验证,这样的报表给客户确实很说不过去. SSRS 可以匿名登录的设定步骤: 环境:   开发工具:SQL Server Business Intel

每次访问报表都需要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

程序共享:

下载

解决后测试页的展示:

到此这篇关于关于 SQL Server Reporting Services 匿名登录的解决方案的文章就介绍到这了,更多相关SQL Server Reporting Services内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: SQL Server Reporting Services 匿名登录的问题及解决方案

本文链接: https://www.lsjlt.com/news/167485.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • SQL Server Reporting Services 匿名登录的问题及解决方案
    每次访问报表都需要windows验证,这样的报表给客户确实很说不过去. SSRS 可以匿名登录的设定步骤: 环境:   开发工具:SQL Server Business Intel...
    99+
    2024-04-02
  • Go语言中SQL的常见问题及解决方案
    Go语言是一种流行的编程语言,被广泛应用于开发Web应用程序、API服务和其他类型的软件项目。在Go语言中,与数据库交互通常是非常常见的需求之一,其中使用SQL语言操作数据库更是常见的...
    99+
    2024-04-02
  • VUE 第三方登录:常见问题与解决方案
    第三方登录按钮不显示 问题描述:在页面上添加了第三方登录按钮,但按钮不显示。 解决方案: 检查按钮代码是否正确,确保按钮代码已正确添加到页面中。 检查按钮样式是否正确,确保按钮样式已正确添加到页面中。 检查第三方登录平台是否已正确...
    99+
    2024-02-23
    VUE 第三方登录 常见问题 解决方案 OAuth2.0
  • Sql Server 2008 数据库附加错误:9004问题解决方案
    目录【问题描述】【解决方法】【问题描述】 数据库文件存在异常状况,有可能是因为硬盘有坏区引起的。附加数据库的时候,提示错误9004。 【解决方法】 假设数据库名称为:UFDATA_001_2023 请按顺序执行以下步骤:...
    99+
    2023-08-07
    Sql Server 2008附加错误9004 Sql Server 2008附加数据库错误9004
  • Discuz登录遇到问题?立即查看解决方案!
    Discuz登录遇到问题?立即查看解决方案! 在使用Discuz进行网站开发和论坛搭建过程中,登录是用户最常用到的功能之一。然而,有时候在登录过程中会遇到各种问题,比如无法正常登录、出...
    99+
    2024-03-11
    解决方案 登录 discuz 验证码生成 表单提交
  • Go语言的问题及解决方案
    近年来,随着科技的快速发展,Go语言作为一种高效、简洁的编程语言备受关注。然而,就像任何一种编程语言一样,Go语言也存在着一些不容忽视的缺陷。本文将探讨Go语言存在的一些缺陷,并提供解...
    99+
    2024-02-24
    问题 go语言 缺陷 解决之道
  • SQL Server评估期已过问题的解决方法
    这篇文章将为大家详细讲解有关SQL Server评估期已过问题的解决方法,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。但是,当自己打开之前敲的系统时,总是报...
    99+
    2024-04-02
  • SQL Server 2012 sa用户登录错误18456的解决方法
    今天就跟大家聊聊有关SQL Server 2012 sa用户登录错误18456的解决方法,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。最近想研究下S...
    99+
    2024-04-02
  • SQL Server的IP不能连接问题的解决方法
    这篇文章将为大家详细讲解有关SQL Server的IP不能连接问题的解决方法,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。自己电脑上安装的SQLServer...
    99+
    2024-04-02
  • 腾讯云服务器异常登录问题解决方案
    1. 异常登录问题的背景 腾讯云服务器是一种强大的云计算服务,但有时候会遇到异常登录的问题。这可能是由于安全漏洞、密码泄露、恶意攻击等原因导致的。为了保护服务器的安全,我们需要采取一些措施来解决这个问题。 2. 异常登录问题的解决方案 #...
    99+
    2023-10-28
    腾讯 异常 解决方案
  • SQL Server数据库安装时常见问题以及解决方法
    这期内容当中小编将会给大家带来有关SQL Server数据库安装时常见问题以及解决方法,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。常见问题一:安装Sql Server ...
    99+
    2024-04-02
  • 阿里云服务器无法登录问解析及解决方案
    在使用阿里云服务器的过程中,我们可能会遇到无法登录的情况,这可能是由于多种原因导致的,如账户被锁定、网络问题、服务器配置问题等。本文将对这个问题进行详细的解析,并提供一些可能的解决方案。 在使用阿里云服务器的过程中,如果无法登录,可能会对我...
    99+
    2023-10-30
    阿里 解决方案 服务器
  • WebSocket协议的跨域问题及解决方案
    随着前端技术的发展,WebSocket协议在实时通信方面扮演着重要的角色。然而,由于跨域安全策略的限制,使用WebSocket协议进行跨域通信可能会遇到一些问题。本文将介绍WebSocket协议的跨域问题,并提供一些解决方案,同时给出具体的...
    99+
    2023-10-21
    解决方案 跨域问题 WebSocket协议
  • 常见的MySQL锁问题及其解决方案
    MySQL 锁的常见问题与解决方案MySQL 是一种常用的关系型数据库管理系统,它使用锁来实现并发控制,保证数据的一致性和完整性。然而,MySQL 锁的使用也会带来一些问题。本文将介绍一些常见的 MySQL 锁的问题,并提供相应的解决方案。...
    99+
    2023-12-21
    解决方案 常见问题 MySQL
  • Cookie设置的常见问题及解决方案
    Cookie设置的常见问题及解决方案,需要具体代码示例 随着互联网的发展,Cookie作为一种最常见的常规技术,已经广泛应用于网站和应用程序中。Cookie,简单来说,是一种存储在用户计算机上的数据文件,可用于存储用户在网站上的...
    99+
    2024-01-19
    解决方案 cookie 设置
  • Node.js Apollo Server Lambda 的陷阱:常见问题和解决方案
    使用 Node.js Apollo Server Lambda 时的陷阱:常见问题和解决方案 使用 Node.js Apollo Server Lambda 可以轻松无缝地构建无服务器 GraphQL API。然而,在开发和部署过程中,可...
    99+
    2024-02-29
    Node.js、Apollo Server、Lambda、陷阱、解决方案
  • 华为云服务器远程桌面登录问题解决方案
    1. 确保远程桌面服务已启用 在使用华为云服务器进行远程桌面登录之前,首先需要确保远程桌面服务已经启用。你可以按照以下步骤进行检查和启用: 登录到华为云服务器控制台。 在左侧导航栏中选择“云服务器 ECS”。 在云服务器列表中找到你要登...
    99+
    2023-10-27
    华为 远程桌面 解决方案
  • win10+anaconda安装yolov5的方法及问题解决方案
    目录YOLOV5-3.0/3.1版本版本问题YOLOV5-4.0版本电脑配置过程中的一些报错报错1:打开摄像头报错报错2:摄像头报错报错3:在创建虚拟环境后,安装库的时候出现错误报错...
    99+
    2024-04-02
  • Python中的并行编程问题及解决方案
    Python中的并行编程问题及解决方案,需要具体代码示例随着多核处理器的普及和计算任务的复杂化,以及数据处理方面的需求增加,利用并行编程可以有效地提高程序的执行效率。Python作为一种高级编程语言,具有简洁、易读、易写的特点,也提供了一些...
    99+
    2023-10-22
    解决方案 并行编程 关键词:Python
  • 阿里云服务器无法SSH登录问分析及解决方案
    简介:本文将对阿里云服务器无法SSH登录的问题进行深入分析,并提供相应的解决方案。SSH是一种安全协议,用于在Linux和Unix系统之间传输数据。然而,在使用阿里云服务器时,可能会遇到无法通过SSH登录的问题。本文将探讨可能的原因,并提供...
    99+
    2024-01-25
    阿里 解决方案 服务器
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作