Definition
connectionStatusReturns information about the current connection, specifically the state of authenticated users and their available permissions.
{ connectionStatus: 1, showPrivileges: <boolean> } connectionStatussupports the following optional field:FieldTypeDescriptionshowPrivilegesboolean
Optional. Set
showPrivilegesto true to instructconnectionStatusto return the full set of privileges that currently-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.authInfoA document with data about the authentication state of the current connection, including users and available permissions.
connectionStatus.authinfo.authenticatedUserRolesAn array with documents for each role granted to the current connection:
connectionStatus.authinfo.authenticatedUserRoles[n].roleThe 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].dbThe database to which
roleapplies.
connectionStatus.authInfo.authenticatedUserPrivilegesAn array with documents describing the actions granted to the current connection, grouped by resource.
connectionStatus.authInfo.authenticatedUserPrivileges[n].resourceA document describing the database and, if applicable, collection to which
connectionStatus.authInfo.authenticatedUserPrivileges[n].actionsapplies.