如何允许用户sp_configure执行文件和cmd shell

时间:2014-04-02 14:33:07

标签: sql sql-server sql-server-2008 configure

在存储过程中,我执行master.dbo.sp_fileexistmaster.dbo.xp_cmdshell,当我使用SA用户时,它的工作非常好,但是当我使用{{}时{1}}用户,我有这个错误。

db_owner

但我也需要使用sp_configure来允许xp_cmdshell。

[FR]
Msg 15247, Niveau 16, État 1, Procédure sp_configure, Ligne 94
L'utilisateur n'est pas autorisé à effectuer cette action.
[/FR]
[EN]
Msg 15247, Level 16, State 1, Procedure sp_configure, Line 94 
The user is not authorized to perform this action.
[/EN]

如果有人可以帮助我,请。

2 个答案:

答案 0 :(得分:1)

对于不是SQL Server实例上sysadmin角色成员的用户,您需要执行以下操作以授予对xp_cmdshell扩展存储过程的访问权限。
*系统管理员可以使用sp_configure。*

启用“xp_cmdshell”
  • 启用xp_cmdshell过程:

    EXEC sp_configure 'show advanced options', 1
    RECONFIGURE
    GO
    
    EXEC sp_configure 'xp_cmdshell', 1
    RECONFIGURE
    GO
    
  • 为xp_cmdshell存储过程授予EXEC权限:

    GRANT EXECUTE ON xp_cmdshell TO [Domain\TestUser]

要自己动手,你需要 serveradmin或sysadmin权限权限

答案 1 :(得分:0)

我建议您使用sp_configure创建一个存储过程以允许其中的xp_cmdshell并使用偶数参数传递给sp_configure过程,创建一个执行为所有者的过程,而不是将此过程的执行权限授予您喜欢的用户:)

我认为通过这种方式你正确而安全地做事

我希望这会对你有所帮助。

祝你好运