AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

connectionStatus(データベースコマンド)

connectionStatus

現在の接続に関する情報、具体的には認証されたユーザーの状態と使用可能な権限を返します。

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

このコマンドの構文は、次のとおりです。

db.runCommand(
{
connectionStatus: 1,
showPrivileges: <boolean>
}
)

connectionStatus 次のオプション フィールドをサポートします。

フィールド
タイプ
説明

showPrivileges

ブール値

Optional. Set showPrivileges to true to instruct connectionStatus to return the full set of privileges that currently-authenticated users possess.

デフォルトでは、このフィールドは false です。

To run connectionStatus use the db.runCommand() method, as in the following:

db.runCommand( { connectionStatus: 1, showPrivileges: true } )
connectionStatus.authInfo

ユーザーや利用可能な権限など、現在の接続の認証状態に関するデータを含むドキュメント。

connectionStatus.authinfo.authenticatedUsers

認証された各ユーザーのドキュメントを含む配列。

connectionStatus.authInfo.authenticatedUsers[n].user

ユーザー名。

connectionStatus.authInfo.authenticatedUsers[n].db

ユーザーの認証情報に関連付けられているデータベース。

connectionStatus.authinfo.authenticatedUserRoles

現在の接続に付与されている各ロールのドキュメントを含む配列:

connectionStatus.authinfo.authenticatedUserRoles[n].role

現在認証されているユーザーに関連付けられている現在のロールの定義。詳しくは、「組み込みロール」および「権限アクション」を参照してください。

connectionStatus.authinfo.authenticatedUserRoles[n].db

The database to which role applies.

connectionStatus.authInfo.authenticatedUserPrivileges

現在の接続に許可されているアクションを説明するドキュメントの配列。リソースごとにグループ化されています。

connectionStatus.authInfo.authenticatedUserPrivileges[n].resource

A document describing the database and, if applicable, collection to which connectionStatus.authInfo.authenticatedUserPrivileges[n].actions applies.

connectionStatus.authInfo.authenticatedUserPrivileges[n].actions

指定されたリソースに対して接続がアクセスできる権限アクションをリストする配列。

connectionStatus.ok

コマンドの戻り値です。値が1の場合は成功を示します。

このページを評価