当前位置:Gxlcms > 数据库问题 > Security7:管理SQL Server Agent的权限

Security7:管理SQL Server Agent的权限

时间:2021-07-01 10:21:17 帮助过:20人阅读

SQLAgentUserRoleSQLAgentReaderRole 和SQLAgentOperatorRole 都对自己创建的Job具有操作权限,都不能修改Job的所有权:

技术分享图片

sysadmin 角色的成员,具有SQL Server Agent的全部权限,能够修改Job的所有权。

二,执行Job Step的权限

在执行Job Step时,SQL Server Agent使用两种类型的权限,分别是Job Owner和代理(Proxy)。如果创建的Job Step是 Transact-SQL script (T-SQL) 类型,那么使用Job Owner的权限去执行TSQL脚本;如果创建的Job Step是另外11种类型种的一种,那么使用代理的权限去执行Job Step。在Job Step执行之前,Agent模拟凭证指定的Windows User的权限,在该权限范围(Security Context)内执行Job Step,使Job Step有权限访问SQL Server 实例之外的资源。

代理(Proxy)使得Job Step在特定的安全上下文中执行,DBA需要创建代理,并为代理设置必须的权限。

SQL Server Agent lets the database administrator run each job step in a security context that has only the permissions required to perform that job step, which is determined by a SQL Server Agent proxy. To set the permissions for a particular job step, you create a proxy that has the required permissions and then assign that proxy to the job step. A proxy can be specified for more than one job step. For job steps that require the same permissions, you use the same proxy.

1,创建代理

每一个Proxy都关联一个凭证(Credential),凭证定义了执行Job Step的安全上下文(Security Context)。使用SSMS创建代理,在SQL Server Agent目录下打开新建代理账户(New Proxy Account)的向导,输入新建的代理名称和关联的凭证名称,从11个子系统(subsystem)列表中选择“SQL Server Intergration Services Package”,该子系统用于执行SSIS的Package。

技术分享图片

技术分享图片

由于代理的权限是由凭证决定的,因此,在创建代理时,为了有效管控执行Job Step的权限,一般情况下,需要为代理(Proxy)创建专用的用户账户,并未用户授予必需的权限,

  • Create dedicated user accounts specifically for proxies, and only use these proxy user accounts for running job steps.

  • Only grant the necessary permissions to proxy user accounts. Grant only those permissions actually required to run the job steps that are assigned to a given proxy account.

2,授予Login访问代理的权限

在SQL Server中,不是所有的login都有权限访问Proxy。为Proxy添加服务器级别(Server-Level)的安全主体(Login),授予其访问Proxy的权限,这样,用户就能够引用Proxy去执行Job Step。

在Principals Tab中,授予Login,服务器角色(server role)或msdb数据库角色访问Proxy的权限。只有被授予访问Proxy权限的Principal,才能在Job Step中使用Proxy。默认情况下,固定服务器角色 sysadmin的成员有权限访问实例中的所有Proxy。

 技术分享图片

3,引用代理

如果Login有权限访问Proxy,或者Login属于有权限访问Proxy的服务器角色(Server Role),那么用户能够在Job Step中使用Proxy,例如,在创建Job Step,从Run as 列表种选择可访问的Proxy:

技术分享图片

三,安全组(Security Group)

在Windows 域环境中,如果把Job的Owner设置为Security Group(SG),该组的成员无法访问该Job,只有把Job的Owner设置为用户的Windows 账户时,用户才能操作Job。

 

参考文档:

SQL Server Agent

Implement SQL Server Agent Security

SQL Server Agent Fixed Database Roles

Security7:管理SQL Server Agent的权限

标签:logs   service   admin   调度   最小   dba   固定   资源   ted   

人气教程排行