每次访问报表都需要windows验证,这样的报表给客户确实很说不过去.
ssrs 可以匿名登录的设定步骤:
环境:
开发工具:sql server business intelligence development studio
数据库: sql2008
首先确定你的reporting services 目录位置
默认为:c:program filesmicrosoft sql servermsrs11.mssqlserverreporting servicesreportserver
打开目录会修改该目录下的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. 从微软下载匿名登录的范例项目
( 下载网址 https://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 servicesreportserverbin 下, (注意别把这个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 filesmicrosoft sql servermsrs11.mssqlserverreporting servicesreportserverbinmicrosoft.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 filesmicrosoft sql servermsrs10.mssqlserverreporting servicesreportserver"; }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 + @"binmicrosoft.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 + @"binmicrosoft.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 + @"binmicrosoft.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内容请搜索<计算机技术网(www.ctvol.com)!!>以前的文章或继续浏览下面的相关文章希望大家以后多多支持<计算机技术网(www.ctvol.com)!!>!
需要了解更多数据库技术:SQL Server Reporting Services 匿名登录的问题及解决方案,都可以关注数据库技术分享栏目—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/1239980.html