> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/m/mongodb-atlas-database-users.md).

# MongoDB Atlas Database Users

MongoDB Atlas is the managed MongoDB service. This adapter reads the database users of every Atlas project the service account can see. Database users are the accounts that connect to the databases, not the people who sign in to Atlas.

## Use cases

* List the Atlas database users.

```
Adapters = mongodb-atlas-database-users
```

## Before you begin

### Network

| Source              | Destination                                                                      | Port | Protocol |
| ------------------- | -------------------------------------------------------------------------------- | ---- | -------- |
| OctoXLabs connector | `cloud.mongodb.com` (default) or `cloud.mongodbgov.com` for Atlas for Government | 443  | HTTPS    |

### Required permissions

| Scope or role                              | Permission | Needed for                                                                |
| ------------------------------------------ | ---------- | ------------------------------------------------------------------------- |
| Organization Read Only (organization role) | Read       | Projects and database users of the organization                           |
| Project Read Only (project role)           | Read       | Database users of each project, when you do not use the organization role |

If the organization requires an IP access list for the Atlas Administration API, add the IP address of the OctoXLabs server to the access list of the service account. Atlas returns no email address for database users, so they are identified by user name. LDAP and OIDC group principals are skipped.

## Create credentials in MongoDB Atlas Database Users

{% stepper %}
{% step %}

### Open Organization Access Manager

Log in to MongoDB Atlas and open the Organization Access Manager page of your organization.
{% endstep %}

{% step %}

### Create a service account

Open the Applications tab and create a new Service Account.
{% endstep %}

{% step %}

### Name it and set the role

Give it a descriptive name and assign Organization Read Only, or add it to each project with Project Read Only.
{% endstep %}

{% step %}

### Copy the credentials

After you select create, copy the Client ID and Client Secret. The secret is shown only once.
{% endstep %}

{% step %}

### Update the access list

If required, add the IP address of the OctoXLabs server to the access list of the service account.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                       | Required | Type    | Default           | Description                                                                           |
| ------------------------------- | -------- | ------- | ----------------- | ------------------------------------------------------------------------------------- |
| Domain (`domain`)               | No       | String  | cloud.mongodb.com | Atlas Administration API domain. Use `cloud.mongodbgov.com` for Atlas for Government. |
| Client ID (`client_id`)         | Yes      | String  |                   | Client ID of the service account.                                                     |
| Client Secret (`client_secret`) | Yes      | String  |                   | Client Secret of the service account.                                                 |
| Proxy (`proxy`)                 | No       | String  |                   | Proxy host and port, sent as an `http://` proxy URL.                                  |
| Timeout (`timeout`)             | No       | Integer | 30                | Seconds to wait for API responses.                                                    |

## Troubleshooting

| Error message                              | Cause                                                       | Fix                                                    |
| ------------------------------------------ | ----------------------------------------------------------- | ------------------------------------------------------ |
| Status Code: 401                           | The token was rejected after one re-authentication.         | Check the Client ID and Client Secret.                 |
| Max retries exceeded for                   | The API kept returning 429 (rate limit).                    | Wait and run the discovery again.                      |
| Skipping database users of Atlas project : | The users call failed for one project. Logged as a warning. | Check the role of the service account on that project. |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
