定義
revokeRolesFromRole指定された継承ロールをロールから削除します。
Tip
In
mongosh, this command can also be run through thedb.revokeRolesFromRole()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas はクラウドでの MongoDB 配置のための完全管理サービスです
重要
このコマンドは、M0 および Flex クラスターではサポートされていません。詳細については、サポートされていないコマンド を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.runCommand( { revokeRolesFromRole: "<role>", roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ], writeConcern: { <write concern> }, comment: <any> } )
コマンドフィールド
コマンドには次のフィールドがあります:
フィールド | タイプ | 説明 |
|---|---|---|
| string | 継承されたロールを削除するロール。 |
| 配列 | 削除する継承されたロール。 |
| ドキュメント | 任意。 操作の 書込み保証( write concern ) のレベル。 詳しくは、 書込み保証(write concern) の仕様を参照してください。 |
| any | 任意。このコマンドに添付するユーザー指定のコメント。設定すると、このコメントは以下の場所にこのコマンドの記録と合わせて表示されます。
コメントには、有効な BSON 型(string, integer, object, array など)を使用できます。 |
rolesフィールドでは、組み込みロールとユーザー定義ロールの両方を指定できます。
To specify a role that exists in the same database where revokeRolesFromRole runs, you can either specify the role with the name of the role:
"readWrite"
または、次のように、ドキュメントを使用してロールを指定することもできます。
{ role: "<role>", db: "<database>" }
別のデータベースに存在するロールを指定するには、 ドキュメントを使用してロールを指定します。
必要なアクセス権
データベースのロールを取り消すには、データベースに対してrevokeRoleアクションが必要です。
例
emeaデータベース内のpurchaseAgentsロールは、 roles配列にリストされているように、いくつかの他のロールから特権を継承します。
{ "_id" : "emea.purchaseAgents", "role" : "purchaseAgents", "db" : "emea", "privileges" : [], "roles" : [ { "role" : "readOrdersCollection", "db" : "emea" }, { "role" : "readAccountsCollection", "db" : "emea" }, { "role" : "writeOrdersCollection", "db" : "emea" } ] }
The following revokeRolesFromRole operation on the emea database removes two roles from the purchaseAgents role:
use emea db.runCommand( { revokeRolesFromRole: "purchaseAgents", roles: [ "writeOrdersCollection", "readOrdersCollection" ], writeConcern: { w: "majority" , wtimeout: 5000 } } )
purchaseAgentsロールには現在、次のロールが 1 つだけ含まれています。
{ "_id" : "emea.purchaseAgents", "role" : "purchaseAgents", "db" : "emea", "privileges" : [], "roles" : [ { "role" : "readAccountsCollection", "db" : "emea" } ] }