如何检查脚本在哪个用户名下运行?
我有这个脚本:
BACKUP DATABASE timeclockplus TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\backup.bak'
我如何知道哪个用户名正在执行它?我问的原因是因为我想向当前用户名授予额外的权限,这样我就可以写入另一个文件夹,而不是写入该备份文件夹
i have this script:
BACKUP DATABASE timeclockplus TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\backup.bak'
how do i know which username is executing it? the reason i ask is because i want to grant extra privelages to the current username so that instead of writing that backup folder i can write to a different folder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了数据库引擎内部之外,不存在这样的上下文。
根据您最近的问题,您的意思是外部 SQL Server 上下文,它将成为所使用的服务帐户(您可以在 Services.msc 中看到它)。因此,如果您使用的是
domain\Specialuser
,那么您可以对文件夹授予domain\Specialuser
权限。但是,SQL Server 2005 引入了一些应包含在安装时指定的服务帐户的组,并且这些组应用于外部(例如外部 SQL Server)权限
KB 283811 ,但最好查看“查看授予 SQL Server 服务帐户的 Windows NT 权利和特权"。此处提到的组是您对所需文件夹应具有的权限。
There is no context as such except for sa inside the DB engine.
Based on your recent questions, you mean external SQL Server context which will be the service account used (you can see it in Services.msc). So if you are using
domain\Specialuser
then you could permissiondomain\Specialuser
on a folder.However, SQL Server 2005 introduced some groups that should contain the service account specified at install time and these should be used for external (eg outside SQL Server) permissions
Some details in KB 283811 , but best seeing "Reviewing Windows NT Rights and Privileges Granted for SQL Server Service Accounts". The groups mentioned here are what you should permission on your desired folder.
看看
SUSER_SNAME()
。(该页面有点误导,不传递参数会返回当前用户 - SQL 登录或域\用户,具体取决于身份验证模式)
Take a look at
SUSER_SNAME()
.(That page is a bit misleading, passing no param returns the current user - either an SQL Logon or a domain\user depending on the auth mode)