<i id='vB178'><tr id='vB178'><dt id='vB178'><q id='vB178'><span id='vB178'><b id='vB178'><form id='vB178'><ins id='vB178'></ins><ul id='vB178'></ul><sub id='vB178'></sub></form><legend id='vB178'></legend><bdo id='vB178'><pre id='vB178'><center id='vB178'></center></pre></bdo></b><th id='vB178'></th></span></q></dt></tr></i><div id='vB178'><tfoot id='vB178'></tfoot><dl id='vB178'><fieldset id='vB178'></fieldset></dl></div>
  • <legend id='vB178'><style id='vB178'><dir id='vB178'><q id='vB178'></q></dir></style></legend>

    <small id='vB178'></small><noframes id='vB178'>

    • <bdo id='vB178'></bdo><ul id='vB178'></ul>
    <tfoot id='vB178'></tfoot>

        使用动态 SQL 对存储过程的 SQL Server 权限

        SQL Server Permissions on Stored Procs with dynamic SQL(使用动态 SQL 对存储过程的 SQL Server 权限)
        <tfoot id='kNUAq'></tfoot>

              <legend id='kNUAq'><style id='kNUAq'><dir id='kNUAq'><q id='kNUAq'></q></dir></style></legend>
            1. <i id='kNUAq'><tr id='kNUAq'><dt id='kNUAq'><q id='kNUAq'><span id='kNUAq'><b id='kNUAq'><form id='kNUAq'><ins id='kNUAq'></ins><ul id='kNUAq'></ul><sub id='kNUAq'></sub></form><legend id='kNUAq'></legend><bdo id='kNUAq'><pre id='kNUAq'><center id='kNUAq'></center></pre></bdo></b><th id='kNUAq'></th></span></q></dt></tr></i><div id='kNUAq'><tfoot id='kNUAq'></tfoot><dl id='kNUAq'><fieldset id='kNUAq'></fieldset></dl></div>
                  <tbody id='kNUAq'></tbody>
                  <bdo id='kNUAq'></bdo><ul id='kNUAq'></ul>

                  <small id='kNUAq'></small><noframes id='kNUAq'>

                  本文介绍了使用动态 SQL 对存储过程的 SQL Server 权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个具有应用程序角色的数据库.角色成员都属于 Active Directory 中的一个组.我没有授予角色从表中选择的权限,而是授予了角色对其需要调用的所有存储过程的执行权限.

                  I have a database which has an application role. The role members all belong to a group in Active Directory. Instead of giving the role permissions to select from the tables I have given the role execute permissions on all of the stored procedures that it needs to call.

                  除了我的一个存储过程正在构建一些动态 SQL 并调用 sp_executesql 之外,这一切正常.

                  This works fine except for one of my stored procedures which is building up some dynamic SQL and calling sp_executesql.

                  动态 sql 看起来像这样:

                  The dynamic sql looks sort of like this:

                  SET @SQL = N'
                  SELECT * 
                  FROM dbo.uvView1 
                  INNER JOIN uvView2 ON uvView1.Id = uvView2.Id'
                  
                  EXEC sp_executesql @SQL
                  

                  此角色的用户无法调用存储过程.它给出了以下错误,这是我认为的预期:

                  The users in this role are failing to call the stored procedure. It gives the following error which is sort of expected I suppose:

                  对象uvView1"、数据库Foobar"、架构dbo"的 SELECT 权限被拒绝.

                  有没有办法让我的用户成功执行这个过程,而无需为动态 SQL 中的所有视图授予角色权限?

                  Is there a way I can have my users successfully execute this proc without giving the role permissions to all of the views in the dynamic SQL?

                  推荐答案

                  是.

                  向过程中添加 EXECUTE AS CALLER 子句,然后对存储过程进行签名并为 签名 提供所需的权限.这是 100% 安全、可靠和防弹的.请参阅使用证书签署程序.

                  Add an EXECUTE AS CALLER clause to the procedure, then sign the stored procedure and give the required permission to the signature. This is 100% safe, secure and bullet proof. See Signing Procedures with Certificates.

                  这篇关于使用动态 SQL 对存储过程的 SQL Server 权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Accessing another user#39;s table within an Oracle Stored Procedure(在 Oracle 存储过程中访问另一个用户的表)
                  Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                  How to View Oracle Stored Procedure using SQLPlus?(如何使用 SQLPlus 查看 Oracle 存储过程?)
                  How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                  How to Pass Java List of Objects to Oracle Stored Procedure Using MyBatis?(如何使用 MyBatis 将 Java 对象列表传递给 Oracle 存储过程?)
                  Set the variable result, from query(设置变量结果,来自查询)
                      <tbody id='w5qzT'></tbody>

                    <tfoot id='w5qzT'></tfoot>

                      <bdo id='w5qzT'></bdo><ul id='w5qzT'></ul>
                    • <small id='w5qzT'></small><noframes id='w5qzT'>

                        <legend id='w5qzT'><style id='w5qzT'><dir id='w5qzT'><q id='w5qzT'></q></dir></style></legend>

                          • <i id='w5qzT'><tr id='w5qzT'><dt id='w5qzT'><q id='w5qzT'><span id='w5qzT'><b id='w5qzT'><form id='w5qzT'><ins id='w5qzT'></ins><ul id='w5qzT'></ul><sub id='w5qzT'></sub></form><legend id='w5qzT'></legend><bdo id='w5qzT'><pre id='w5qzT'><center id='w5qzT'></center></pre></bdo></b><th id='w5qzT'></th></span></q></dt></tr></i><div id='w5qzT'><tfoot id='w5qzT'></tfoot><dl id='w5qzT'><fieldset id='w5qzT'></fieldset></dl></div>