这是最初发布在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.