Docs 菜单
Docs 主页
/
MongoDB Manual
/ / /

connectionStatus

在此页面上

  • 定义
  • 兼容性
  • 语法
  • 例子
  • 输出
connectionStatus

返回有关当前连接的信息,具体指已验证用户的状态及其可用权限。

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas :用于在云中部署 MongoDB 的完全托管服务

注意

所有 MongoDB Atlas 集群都支持此命令。有关所有命令的信息,请参阅不支持的命令

  • MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本

  • MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本

该命令具有以下语法:

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

connectionStatus 支持以下可选字段:

字段
类型
说明
showPrivileges
布尔

可选。将 showPrivileges 设置为 true 以指示 connectionStatus 返回当前经过身份验证的用户拥有的全部权限

默认情况下,此字段为 false

要运行 connectionStatus,请使用 db.runCommand() 方法,如下所示:

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

role 适用的数据库。

connectionStatus.authInfo.authenticatedUserPrivileges

一个数组,其中包含描述授予当前连接的动作的文档,按资源分组。

connectionStatus.authInfo.authenticatedUserPrivileges[n].resource

一个文档,描述 connectionStatus.authInfo.authenticatedUserPrivileges[n].actions 适用的数据库和集合(如适用)。

connectionStatus.authInfo.authenticatedUserPrivileges[n].actions

一个数组,列出连接有权访问的指定资源的权限操作。

connectionStatus.ok

命令的返回值。值为 1 表示成功。

后退

connPoolStats

来年

数据大小