> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# connectionStatus (database command)

## Definition

Returns information about the current connection, specifically the state of authenticated users and their available permissions.

## Compatibility

This command is available in deployments hosted in the following environments:

- [MongoDB Atlas](https://www.mongodb.com/docs/atlas): The fully managed service for MongoDB deployments in the cloud

**Note:**

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see [Unsupported Commands.](https://www.mongodb.com/docs/atlas/unsupported-commands/)

- [MongoDB Enterprise](https://www.mongodb.com/docs/manual/administration/install-enterprise.md#std-label-install-mdb-enterprise): The subscription-based, self-managed version of MongoDB

- [MongoDB Community](https://www.mongodb.com/docs/manual/administration/install-community.md#std-label-install-mdb-community-edition): The source-available, free-to-use, and self-managed version of MongoDB

## Syntax

The command has the following syntax:

```javascript
db.runCommand(
   {
     connectionStatus: 1,
     showPrivileges: <boolean>
   }
)
```

### Command Fields

[`connectionStatus`](https://www.mongodb.com/docs/manual/reference/command/connectionStatus.md#mongodb-dbcommand-dbcmd.connectionStatus) supports the following optional field:

| Field | Type | Description |
| --- | --- | --- |
| `showPrivileges` | boolean | Optional. Set `showPrivileges` to true to instruct [`connectionStatus`](https://www.mongodb.com/docs/manual/reference/command/connectionStatus.md#mongodb-dbcommand-dbcmd.connectionStatus) to return the full set of [privileges](https://www.mongodb.com/docs/manual/reference/privilege-actions.md#std-label-security-user-actions) that currently-authenticated users possess. By default, this field is `false`. |

## Example

To run [`connectionStatus`](https://www.mongodb.com/docs/manual/reference/command/connectionStatus.md#mongodb-dbcommand-dbcmd.connectionStatus) use the [`db.runCommand()`](https://www.mongodb.com/docs/manual/reference/method/db.runCommand.md#mongodb-method-db.runCommand) method, as in the following:

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

## Output

A document with data about the authentication state of the current connection, including users and available permissions.

An array with documents for each authenticated user.

The user's name.

The database associated with the user's credentials.

An array with documents for each role granted to the current connection:

The definition of the current roles associated with the current authenticated users. See [Built-In Roles](https://www.mongodb.com/docs/manual/reference/built-in-roles.md) and [Privilege Actions](https://www.mongodb.com/docs/manual/reference/privilege-actions.md) for more information.

The database to which [`role`](https://www.mongodb.com/docs/manual/reference/command/connectionStatus.md#mongodb-data-connectionStatus.authinfo.authenticatedUserRoles-n-.role) applies.

An array with documents describing the [actions](https://www.mongodb.com/docs/manual/reference/privilege-actions.md) granted to the current connection, grouped by resource.

A document describing the database and, if applicable, collection to which [`connectionStatus.authInfo.authenticatedUserPrivileges[n].actions`](https://www.mongodb.com/docs/manual/reference/command/connectionStatus.md#mongodb-data-connectionStatus.authInfo.authenticatedUserPrivileges-n-.actions) applies.

An array listing the privilege actions that the connection has access to for the specified resource.

The UUID of the current connected client.

The return value for the command. A value of `1` indicates success.
