db.revokePrivilegesFromRole()
定義
db.revokePrivilegesFromRole(rolename, privileges, writeConcern)
Removes the specified privileges from the user-defined role on the database where the method runs.
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。ただし、データベースコマンドや Node.js などの言語固有のドライバーのドキュメントには該当しません。データベースコマンドについては、
revokePrivilegesFromRole
コマンドを参照してください。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
db.revokePrivilegesFromRole()
メソッドの構文は次のとおりです。db.revokePrivilegesFromRole( "<rolename>", [ { resource: { <resource> }, actions: [ "<action>", ... ] }, ... ], { <writeConcern> } ) db.revokePrivilegesFromRole()
メソッドは次の引数を取ります。Parameterタイプ説明rolename
string
The name of the user-defined role from which to revoke privileges.
privileges
配列
ロールから削除する特権の配列。 特権の形式の詳細については、
privileges
を参照してください。writeConcern
ドキュメント
任意。 操作の 書込み保証( write concern ) のレベル。 詳しくは、 書込み保証(write concern) の仕様を参照してください。
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
重要
このコマンドは、 MongoDB Atlasクラスターではサポートされていません。 すべてのコマンドの Atlas サポートの詳細については、「 サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
レプリカセット
レプリカセットで実行する場合、 db.revokePrivilegesFromRole()
はデフォルトで"majority"
書込み保証を使用して実行されます。
スコープ
特権を取り消すには、リソース ドキュメントパターンがその特権のresource
フィールドと完全に一致する必要があります。
actions
フィールドはサブセットまたは完全一致にすることができます。
For example, given the role accountRole
in the products
database with the following privilege that specifies the products
database as the resource:
{ "resource" : { "db" : "products", "collection" : "" }, "actions" : [ "find", "update" ] }
products
データベース内の1 つのコレクションのみから
find
および/またはupdate
を取り消すことはできません。 次の操作では、 ロールは変更されません。
use products db.revokePrivilegesFromRole( "accountRole", [ { resource : { db : "products", collection : "gadgets" }, actions : [ "find", "update" ] } ] ) db.revokePrivilegesFromRole( "accountRole", [ { resource : { db : "products", collection : "gadgets" }, actions : [ "find" ] } ] )
ロール から "find"
アクションおよび/または"update"
accountRole
アクションを取り消すには、リソース ドキュメントと完全に一致する必要があります。たとえば、次の操作は、既存の特権から"find"
アクションのみを取り消します。
use products db.revokePrivilegesFromRole( "accountRole", [ { resource : { db : "products", collection : "" }, actions : [ "find" ] } ] )
必要なアクセス権
特権を取り消すには、特権ターゲットのデータベースに対してrevokeRole
アクションが必要です。 特権が複数のデータベースまたはcluster
リソースを対象としている場合は、 admin
データベースに対して
revokeRole
アクションが必要です。
例
The following operation removes multiple privileges from the
associates
role:
db.revokePrivilegesFromRole( "associate", [ { resource: { db: "products", collection: "" }, actions: [ "createCollection", "createIndex", "find" ] }, { resource: { db: "products", collection: "orders" }, actions: [ "insert" ] } ], { w: "majority" } )