connectionStatus

在本页面

Definition

  • connectionStatus
    • 返回有关当前连接的信息,特别是经过身份验证的用户的状态及其可用权限。
{ connectionStatus: 1, showPrivileges: <boolean> }

connectionStatus支持以下可选字段:

FieldTypeDescription
showPrivilegesboolean可选的。将showPrivileges设置为 true 可指示connectionStatus返回当前已认证用户拥有的privileges的完整集合。


默认情况下,此字段为false

Example

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

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

Output

  • 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

    • 包含描述授予当前连接的actions的文档的数组,按资源分组。
  • connectionStatus.authInfo.authenticatedUserPrivileges[n]. resource

  • connectionStatus.authInfo.authenticatedUserPrivileges[n]. actions

    • 一个数组,列出连接可以访问的指定资源的特权操作。
  • connectionStatus. ok

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