对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

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.

该命令具有以下语法:

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.authInfo.UUID

当前连接客户端的 UUID。

connectionStatus.ok

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

给本页内容打分