Definition定义
connectionStatusReturns information about the current connection, specifically the state of authenticated users and their available permissions.返回有关当前连接的信息,特别是经过身份验证的用户的状态及其可用权限。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Note
This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
connectionStatus: 1,
showPrivileges: <boolean>
}
)
Command Fields命令字段
connectionStatus supports the following optional field:支持以下可选字段:
showPrivileges |
|
Example示例
To run 要运行connectionStatus use the db.runCommand() method, as in the following:connectionStatus,请使用db.runCommand()方法,如下所示:
db.runCommand( { connectionStatus: 1, showPrivileges: true } )Output输出
connectionStatus.authInfoA document with data about the authentication state of the current connection, including users and available permissions.包含当前连接身份验证状态数据的文档,包括用户和可用权限。
connectionStatus.authinfo.authenticatedUsersAn array with documents for each authenticated user.一个数组,其中包含每个经过身份验证的用户的文档。connectionStatus.authInfo.authenticatedUsers[n].userThe user's name.用户名。
connectionStatus.authInfo.authenticatedUsers[n].dbThe database associated with the user's credentials.与用户凭据关联的数据库。
connectionStatus.authinfo.authenticatedUserRolesAn array with documents for each role granted to the current connection:一个数组,其中包含授予当前连接的每个角色的文档:connectionStatus.authinfo.authenticatedUserRoles[n].roleThe definition of the current roles associated with the current authenticated users. See Built-In Roles and Privilege Actions for more information.与当前已验证用户关联的当前角色的定义。有关更多信息,请参阅内置角色和权限操作。
connectionStatus.authinfo.authenticatedUserRoles[n].dbThe database to which应用roleapplies.role的数据库。
connectionStatus.authInfo.authenticatedUserPrivilegesAn array with documents describing the actions granted to the current connection, grouped by resource.一个数组,其中包含描述授予当前连接的操作的文档,按资源分组。connectionStatus.authInfo.authenticatedUserPrivileges[n].resourceA document describing the database and, if applicable, collection to which描述数据库以及connectionStatus.authInfo.authenticatedUserPrivileges[n].actionsapplies.connectionStatus.authInfo.authenticatedUserPrivileges[n].actions所应用的集合(如果适用)的文档。
connectionStatus.authInfo.authenticatedUserPrivileges[n].actionsAn array listing the privilege actions that the connection has access to for the specified resource.列出连接对指定资源有权访问的权限操作的数组。
connectionStatus.authInfo.UUIDThe UUID of the current connected client.当前连接的客户端的UUID。
connectionStatus.okThe return value for the command. A value of命令的返回值。值为1indicates success.1表示成功。