0

背景

我正在使用 SQL Server 2008 R2 的全文搜索来检索一些文档,并希望使用结果sys.dm_fts_parser来突出显示匹配的术语。

这样做通常需要应用程序用户不应该拥有的权限。MSDN 上提出了一个解决方案,StackOverflow 上也有一个已删除的问题/答案(请参阅为什么它被删除)。

问题

我正在尝试实施该解决方案,但无法向 IIS 应用程序池用户授予执行权限。

我试过的

在安全/登录下的 SSMS 中,我创建了一个用户IIS APPPOOL\My App。我授予该用户db_datareaderdb_datawriter表访问权限,并且效果很好。

再次在 SSMS 中:

  • 在 MyDB / Programmability / Stored Procedures 我右键单击dbo.usp_fts_parser
  • 选择属性、权限。
  • 点击搜索...
  • 添加IIS APPPOOL\My App
  • 在显式选项卡上,执行行我检查授予
  • 点击确定

问题

为什么这笔赠款不足以执行dbo.usp_fts_parser

笔记

  • 我可以从以管理员身份登录的 SSMS 执行它。
  • 如果我暂时将 sysadmin 服务器角色授予IIS APPPOOL\My App,则代码能够执行dbo.usp_fts_parser
4

2 回答 2

2

如果您查看此系统功能的官方 MSDN 帮助,您会发现它实际上需要,

权限

需要 sysadmin 固定服务器角色的成员资格和对指定停止列表的访问权限。

就像说的那样,该用户必须是 sysadmin 固定服务器角色的成员。我认为没有任何解决方法。

于 2013-03-30T01:41:25.647 回答
1

这是最初发布在https://stackoverflow.com/questions/3816023/sys-dm-fts-parser-permission/3816407#3816407的答案:

在您的数据库中:

create procedure usp_fts_parser
    @query nvarchar(max)
with execute as caller
as
select * from sys.dm_fts_parser(@query, 1033, 0, 0);
go

grant execute on usp_fts_parser to [<some low priviledged user>]
go

create certificate sign_fts_parser
    encryption by password = 'Password#1234'
    with subject = 'sign_fts_parser';
go

add signature to object::usp_fts_parser
by certificate sign_fts_parser with password = 'Password#1234';
go

alter certificate sign_fts_parser
remove private key;
go

backup certificate sign_fts_parser
to file = 'c:\temp\sign_fts_parser.cer';
go

在大师:

create certificate sign_fts_parser
from file = 'c:\temp\sign_fts_parser.cer';
go  

create login login_sign_fts_parser
from certificate sign_fts_parser;
go

grant control server to login_sign_fts_parser;
go

我刚刚在 SQL Server 2008 上测试了这些步骤,并且能够usp_fts_parser从低权限登录执行。与原始帖子答案的唯一区别是我在存储过程上添加了显式 GRANT EXECUTE 并删除了单相启用的可信赖步骤。在您的情况下<low priviledged user>应该是IIS APPPOOL\My App,假设您不在ASP 应用程序中使用模拟。

The required permissions on calling sys.dm_fts_parser are being derived from the signature on the procedure which, via the certificate exported and imported into master database, has explicit CONTROL SERVER permission (highest possible priviledge). Because the private key of the certificate was explicitly removed there is no way to abuse the high priviledge associated with this certificate, since it cannot ever sign again anything (the private key is lost forever). See Module Signing (Database Engine) for more details.

Note that the steps above have to be repeated every time you modify the stored procedure. Any ALTER on the procedure will result in an automated, silent, drop of the associated signature. Loosing the module signature implies loosing the priviledges derived from this signature and thus the subsequent calls to sys.dm_fts_parser will fail for a low priviledged user.

于 2013-04-02T10:43:00.727 回答