- Reference >
- Database Commands >
- Role Management Commands >
- revokePrivilegesFromRole
revokePrivilegesFromRole¶
On this page
Definition¶
-
revokePrivilegesFromRole
¶ Removes the specified privileges from the user-defined role on the database where the command is run. The
revokePrivilegesFromRole
command has the following syntax:The
revokePrivilegesFromRole
command has the following fields:Field Type Description revokePrivilegesFromRole
string The user-defined role to revoke privileges from. privileges
array An array of privileges to remove from the role. See privileges
for more information on the format of the privileges.writeConcern
document Optional. The level of write concern for the modification. The writeConcern
document takes the same fields as thegetLastError
command.comment
any Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
- mongod log messages, in the
attr.command.cursor.comment
field. - Database profiler output, in the
command.comment
field. currentOp
output, in thecommand.comment
field.
A comment can be any valid BSON type (string, integer, object, array, etc).
New in version 4.4.
- mongod log messages, in the
Behavior¶
To revoke a privilege, the resource document pattern must match exactly the
resource
field of that privilege. The actions
field can be a
subset or match exactly.
For example, consider the role accountRole
in the products
database with the following privilege that specifies the products
database as the resource:
You cannot revoke find
and/or update
from just one
collection in the products
database. The following operations
result in no change to the role:
To revoke the "find"
and/or the "update"
action from the role
accountRole
, you must match the resource document exactly. For
example, the following operation revokes just the "find"
action
from the existing privilege.
Required Access¶
You must have the revokeRole
action on the database a privilege targets in order to
revoke that privilege. If the privilege targets multiple databases or the
cluster
resource, you must have the revokeRole
action
on the admin
database.
Example¶
The following operation removes multiple privileges from the
associates
role in the products
database: