定义
兼容性
此命令可用于以下环境中托管的部署:
- 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 支持以下可选字段:
字段 | 类型 | 说明 |
|---|---|---|
| 布尔 | Optional. Set 默认情况下,此字段为 |
例子
To run connectionStatus use the db.runCommand() method, as in the following:
db.runCommand( { connectionStatus: 1, showPrivileges: true } )
输出
connectionStatus.authinfo.authenticatedUserRoles一个数组,其中包含授予当前连接的每个角色的文档:
connectionStatus.authinfo.authenticatedUserRoles[n].dbThe database to which
roleapplies.
connectionStatus.authInfo.authenticatedUserPrivileges一个数组,其中包含描述授予当前连接的动作的文档,按资源分组。
connectionStatus.authInfo.authenticatedUserPrivileges[n].resourceA document describing the database and, if applicable, collection to which
connectionStatus.authInfo.authenticatedUserPrivileges[n].actionsapplies.