创建一个数据库 user/role 有权授予 dbo 模式
Create an database user/role that has the permission to grant on dbo schema
我在架构 dbo 下有一些存储过程。
我还有数据库级别的角色:Tech,以及数据库级别的用户:Jack。杰克是 Tech 的成员。
作为 sa 我可以 运行:
GRANT EXEC ON SCHEMA :: dbo TO Tech
那么 Jack 将拥有对所有存储过程的 EXEC 权限。现在我想知道的是,是否有办法让我 运行 不是 sa,而是 Jack 的相同命令,以向 Jack 创建的其他用户授予相同的 EXEC 权限(Jack 确实有权创建服务器级登录、数据库级 users/roles 等)?换句话说,sa 需要给 Jack 什么权限,Jack 才能将 EXEC 授予模式 dbo 下的所有存储过程?
更新:我刚刚测试并发现将模式 dbo 的控制权授予 Jack 可以做到这一点。我现在的问题是:CONTROL 是否是使 Jack 能够在模式 dbo 上授予 EXEC 所需的绝对最小值?
如果您需要授予某人对某事的权限,并授予他们权限然后将其授予其他人,您需要使用 WITH GRANT 子句进行 GRANT。
经测试,WITH GRANT OPTION似乎只对用户有效,对角色无效。使用我原来问题中的示例,我们有角色 Tech 和用户 Jack,其中 Jack 是 Tech 的成员:
运行 GRANT EXEC ON SCHEMA :: dbo TO Tech WITH GRANT OPTION;不会让 Jack 将 EXEC 授予其他用户。
然而 运行 GRANT EXEC ON SCHEMA :: dbo TO Jack WITH GRANT OPTION;将工作。
Greg 的回答在某种程度上是正确的,他应该得到赞扬。尽管由于我自己弄清楚了细节,所以我将使用自己的答案。
更新:更多信息,在 Microsoft 文档中找到 this:
The GRANT ... WITH GRANT OPTION specifies that the security principal
receiving the permission is given the ability to grant the specified
permission to other security accounts. When the principal that
receives the permission is a role or a Windows group, the AS clause
must be used when the object permission needs to be further granted to
users who are not members of the group or role. Because only a user,
rather than a group or role, can execute a GRANT statement, a specific
member of the group or role must use the AS clause to explicitly
invoke the role or group membership when granting the permission. The
following example shows how the WITH GRANT OPTION is used when granted
to a role or Windows group.
我在架构 dbo 下有一些存储过程。
我还有数据库级别的角色:Tech,以及数据库级别的用户:Jack。杰克是 Tech 的成员。
作为 sa 我可以 运行:
GRANT EXEC ON SCHEMA :: dbo TO Tech
那么 Jack 将拥有对所有存储过程的 EXEC 权限。现在我想知道的是,是否有办法让我 运行 不是 sa,而是 Jack 的相同命令,以向 Jack 创建的其他用户授予相同的 EXEC 权限(Jack 确实有权创建服务器级登录、数据库级 users/roles 等)?换句话说,sa 需要给 Jack 什么权限,Jack 才能将 EXEC 授予模式 dbo 下的所有存储过程?
更新:我刚刚测试并发现将模式 dbo 的控制权授予 Jack 可以做到这一点。我现在的问题是:CONTROL 是否是使 Jack 能够在模式 dbo 上授予 EXEC 所需的绝对最小值?
如果您需要授予某人对某事的权限,并授予他们权限然后将其授予其他人,您需要使用 WITH GRANT 子句进行 GRANT。
经测试,WITH GRANT OPTION似乎只对用户有效,对角色无效。使用我原来问题中的示例,我们有角色 Tech 和用户 Jack,其中 Jack 是 Tech 的成员:
运行 GRANT EXEC ON SCHEMA :: dbo TO Tech WITH GRANT OPTION;不会让 Jack 将 EXEC 授予其他用户。
然而 运行 GRANT EXEC ON SCHEMA :: dbo TO Jack WITH GRANT OPTION;将工作。
Greg 的回答在某种程度上是正确的,他应该得到赞扬。尽管由于我自己弄清楚了细节,所以我将使用自己的答案。
更新:更多信息,在 Microsoft 文档中找到 this:
The GRANT ... WITH GRANT OPTION specifies that the security principal receiving the permission is given the ability to grant the specified permission to other security accounts. When the principal that receives the permission is a role or a Windows group, the AS clause must be used when the object permission needs to be further granted to users who are not members of the group or role. Because only a user, rather than a group or role, can execute a GRANT statement, a specific member of the group or role must use the AS clause to explicitly invoke the role or group membership when granting the permission. The following example shows how the WITH GRANT OPTION is used when granted to a role or Windows group.