connectionStatus
Definition
connectionStatus
- Returns information about the current connection, specifically thestate of authenticated users and their available permissions.
- { connectionStatus: 1, showPrivileges: <boolean> }
connectionStatus
supports the following optionalfield:
FieldTypeDescriptionshowPrivileges
booleanOptional. Set showPrivileges
to true to instructconnectionStatus
to return the full set ofprivileges thatcurrently-authenticated users possess.
By default, this field is false
.
Example
To run connectionStatus
use the db.runCommand()
method, as in the following:
- db.runCommand( { connectionStatus: 1, showPrivileges: true } )
Output
connectionStatus.
authInfo
- A document with data about the authentication state of the currentconnection, including users and available permissions.
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 currentauthenticated users. See Built-In Roles andPrivilege Actions for more information.
- The database to which
role
applies.
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, collectionto which
connectionStatus.authInfo.authenticatedUserPrivileges[n].actions
applies.connectionStatus.authInfo.authenticatedUserPrivileges[n].
actions
- An array listing the privilege actions thatthe connection has access to for the specified resource.