connectionStatus
定义
兼容性
此命令在以下环境中部署的部署中可用
MongoDB Atlas:MongoDB在云中的全面托管服务
注意
此命令在所有MongoDB Atlas集群中受支持。有关所有命令的Atlas支持信息,请参阅不受支持的命令。
MongoDB Enterprise:基于订阅的、自我管理的MongoDB版本
MongoDB Community:源代码可用的、免费使用和自我管理的MongoDB版本
语法
该命令的语法如下
db.runCommand( { connectionStatus: 1, showPrivileges: <boolean> } )
命令字段
connectionStatus
支持以下可选字段
字段 | 类型 | 描述 |
---|---|---|
showPrivileges | 布尔型 | 可选。将 默认情况下,该字段为 |
示例
要运行 connectionStatus
,请使用 db.runCommand()
方法,如下所示
db.runCommand( { connectionStatus: 1, showPrivileges: true } )
输出
connectionStatus.authinfo.authenticatedUserRoles
包含分配给当前连接的每个角色的文档数组。
connectionStatus.authinfo.authenticatedUserRoles[n].role
当前认证用户关联的当前角色的定义。有关更多信息,请参阅自托管部署中的内置角色和自托管部署的权限操作。
connectionStatus.authinfo.authenticatedUserRoles[n].db
应用
role
的数据库。
connectionStatus.authInfo.authenticatedUserPrivileges
一个数组,包含描述当前连接所授予的操作的文档,按资源分组。
connectionStatus.authInfo.authenticatedUserPrivileges[n].resource
一个描述
connectionStatus.authInfo.authenticatedUserPrivileges[n].actions
应用的数据库和(如果适用)集合的文档。