我从同事中继承了一个使用xp_cmdshell
的存储过程。为了为特定登录启用此功能,我需要运行以下命令来启用它。
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
我已经添加了对此特定登录的sysadmin服务器角色访问权限,并且运行此存储过程到目前为止需要访问sysadmin。
我们已在开发SQL Server中为此特定用户授予了sysadmin访问权限。当我们将存储过程迁移到生产环境时,DBA担心这个用户在生产环境中有太多特权。
在生产环境中没有sysadmin访问权限的情况下,我们是否可以继续使用此登录名继续运行存储过程?
提前感谢您的帮助。
答案 0 :(得分:0)
感谢所有帮助。我在这里继续评论,因为我需要示例代码的标记。
存储过程尝试执行基本文件IO操作,以将文件移动,复制,删除到网络驱动器。
e.g. exec @ret_val = master..xp_cmdshell @stmt, no_output @stmt
@stmt can be "copy //hostname/mapdrive/subdirectory/somefile //hostname/mapped directory" using sharing mechanism.
or create a subdirectory.
e.g. select @stmt = 'md '+@pri_path
我相信他们使用存储过程执行此操作,因此它们可以包含存储过程中的所有文件I / O操作。
至于xp_cmd_shell_proxy_account,我找到了这个https://msdn.microsoft.com/en-us/library/ms190359.aspx。根据我的解释,我们为sql server提供了一个windows登录用户名和密码,以获得对shell的访问权限。我对么?
感谢。