用户看不到SQL Server Agent组件如何处理

本文详细解析了SQL Server Agent的三种固定数据库角色:SQLAgentUserRole、SQLAgentReaderRole和SQLAgentOperatorRole,以及sysadmin角色的权限差异。针对无法查看SQL Server Agent组件的问题,文章提供了解决方案,并介绍了各角色的具体权限,帮助理解SQL Server Agent的安全控制。
摘要由CSDN通过智能技术生成

开发反馈需要看job执行情况,但登录之后发现看不到SQL Server Agent组件,需要帮忙处理。

一、 解决方法

登上服务器检查了下SQL Server Agent服务运行正常,使用管理员账号登录能看到该组件。

可以猜到这个问题应该跟权限有关,查到官方文档介绍如下:

SQL Server使用msdb数据库管理Agent 对象权限,msdb内置三个数据库角色,权限从小到大依次是:SQLAgentUserRole -> SQLAgentReaderRole -> SQLAgentOperatorRole(大权限角色包含小权限)。如果用户不是这三个角色或sysadmin角色中的成员,则无法通过SSMS的Object Explorer看到及使用SQL Server Agent组件。

SQL Server has the following msdb database fixed database roles, which give administrators finer control over access to SQL Server Agent. The roles listed from least to most privileged access are:

  • SQLAgentUserRole

  • SQLAgentReaderRole

  • SQLAgentOperatorRole

When users who are not members of one of these roles are connected to SQL Server in SQL Server Management Studio, the SQL Server Agent node in Object Explorer is not visible. A user must be a member of one of these fixed database roles or a member of the sysadmin fixed server role to use SQL Server Agent.

如果只需要看,给到SQLAgentReaderRole就够了;如果需要启停job,需要给到SQLAgentOperatorRole

刷新再看,发现可以看到agent组件了

 

二、 相关角色简介

解决完问题再来看下官方文档对相关角色的描述:

SQLAgentUserRole 角色被授予操作Agent的最小权限,仅对自己创建的local jobs和job schedules有操作权限。无multiserver jobs (master and target server jobs) 操作权限,也不能修改Job的所有权关系

SQLAgentReaderRole 角色,额外具有Multiserver jobs的查看权限,其余和SQLAgentUserRole相同。如果用户被授予该权限,在SSMS的agent组件中只能看到job部分。

SQLAgentOperatorRole 角色,额外具有查看Alert列表和属性的权限,其余和SQLAgentReaderRole 相同。如果用户被授予该权限,在SSMS的agent组件中能看到所有部分。

三个角色都对自己创建的Job具有操作权限,但都不能修改Job的所有权

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

 

三、 详细权限列表

1. SQLAgentUserRole

ActionOperatorsLocal jobs
(owned jobs only)
Job schedules
(owned schedules only)
Proxies
Create/modify/deleteNoYes
Cannot change job ownership.
YesNo
View list (enumerate)Yes

Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio.
YesYesYes

List of proxies only available in the Job Step Properties dialog box of Management Studio.
Enable/disableNoYesYesNot applicable
View propertiesNoYesYesNo
Execute/stop/startNot applicableYesNot applicableNot applicable
View job historyNot applicableYesNot applicableNot applicable
Delete job historyNot applicableNo

Members of SQLAgentUserRole must explicitly be granted the EXECUTE permission on sp_purge_jobhistory to delete job history on jobs that they own. They cannot delete job history for any other jobs.
Not applicableNot applicable
Attach/detachNot applicableNot applicableYesNot applicable

 

2. SQLAgentReaderRole

ActionOperatorsLocal jobsMultiserver jobsJob schedulesProxies
Create/modify/deleteNoYes (owned jobs only)
Cannot change job ownership.
NoYes (owned schedules only)No
View list (enumerate)Yes

Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio.
YesYesYesYes

List of proxies only available in the Job Step Properties dialog box of Management Studio.
Enable/disableNoYes (owned jobs only)NoYes (owned schedules only)Not applicable
View propertiesNoYesYesYesNo
Edit propertiesNoYes (owned jobs only)NoYes (owned schedules only)No
Execute/stop/startNot applicableYes (owned jobs only)NoNot applicableNot applicable
View job historyNot applicableYesYesNot applicableNot applicable
Delete job historyNot applicableNo

Members of SQLAgentReaderRole must explicitly be granted the EXECUTE permission on sp_purge_jobhistory to delete job history on jobs that they own. They cannot delete job history for any other jobs.
NoNot applicableNot applicable
Attach/detachNot applicableNot applicableNot applicableYes (owned schedules only)Not applicable

 

3. SQLAgentOperatorRole

ActionAlertsOperatorsLocal jobsMultiserver jobsJob schedulesProxies
Create/modify/deleteNoNoYes (owned jobs only)
Cannot change job ownership.
NoYes (owned schedules only)No
View list (enumerate)YesYes

Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio.
YesYesYesYes
Enable/disableNoNoYes

SQLAgentOperatorRole members can enable or disable local jobs they do not own by using the stored procedure sp_update_job and specifying values for the @enabled and the @job_id (or @job_name) parameters. If a member of this role specifies any other parameters for this stored procedure, execution of the procedure will fail.
NoYes

SQLAgentOperatorRole members can enable or disable schedules they do not own by using the stored procedure sp_update_schedule and specifying values for the @enabled and the @schedule_id (or @name) parameters. If a member of this role specifies any other parameters for this stored procedure, execution of the procedure will fail.
Not applicable
View propertiesYesYesYesYesYesYes
Edit propertiesNoNoYes (owned jobs only)NoYes (owned schedules only)No
Execute/stop/startNot applicableNot applicableYesNoNot applicableNot applicable
View job historyNot applicableNot applicableYesYesNot applicableNot applicable
Delete job historyNot applicableNot applicableYesNoNot applicableNot applicable
Attach/detachNot applicableNot applicableNot applicableNot applicableYes (owned schedules only)Not applicable

 

参考

https://docs.microsoft.com/en-us/sql/ssms/agent/sql-server-agent-fixed-database-roles?view=sql-server-ver15

https://www.cnblogs.com/ljhdo/archive/2017/11/24/5177423.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hehuyi_In

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值