connectionStatus

On this page本页内容

Definition定义

connectionStatus

Returns information about the current connection, specifically the state of authenticated users and their available permissions.返回有关当前连接的信息,特别是已验证用户的状态及其可用权限。

{ connectionStatus: 1, showPrivileges: <boolean> }

connectionStatus supports the following optional field:支持以下可选字段:

Field字段Type类型Description描述
showPrivilegesboolean

Optional. 可选。Set showPrivileges to true to instruct connectionStatus to return the full set of privileges that currently-authenticated users possess.showPrivileges设置为true以指示connectionStatus返回当前经过身份验证的用户所拥有的全部权限集。

By default, this field is false.默认情况下,此字段为false

Example示例

To run connectionStatus use the db.runCommand() method, as in the following:要运行connectionStatus,请使用db.runCommand()方法,如下所示:

db.runCommand( { connectionStatus: 1, showPrivileges: true } )

Output输出

connectionStatus.authInfo

A document with data about the authentication state of the current connection, including users and available permissions.包含有关当前连接的身份验证状态(包括用户和可用权限)的数据的文档。

connectionStatus.authinfo.authenticatedUsers

An array with documents for each authenticated user.包含每个已验证用户的文档的数组。

connectionStatus.authInfo.authenticatedUsers[n].user

The user's name.

connectionStatus.authInfo.authenticatedUsers[n].db

The database associated with the user's credentials.与用户凭据关联的数据库。

connectionStatus.authinfo.authenticatedUserRoles

An array with documents for each role granted to the current connection:一个数组,其中包含授予当前连接的每个角色的文档:

connectionStatus.authinfo.authenticatedUserRoles[n].role

The 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].db

The database to which role applies.应用role的数据库。

connectionStatus.authInfo.authenticatedUserPrivileges

An array with documents describing the actions granted to the current connection, grouped by resource.一个数组,其中包含描述授予当前连接的操作的文档,按资源分组。

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.authenticatedUserPrivileges[n].actions

An array listing the privilege actions that the connection has access to for the specified resource.列出连接对指定资源有权访问的权限操作的数组。

connectionStatus.ok

The return value for the command. 命令的返回值。A value of 1 indicates success.1表示成功。

←  connPoolStatscursorInfo →