Navigation

Get a Single Database User

Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

Base URL: https://cloud.mongodb.com/api/atlas/v1.0

The Atlas API uses HTTP Digest Authentication. Provide a programmatic API public key and corresponding private key as the username and password when constructing the HTTP request.

For complete documentation on configuring API access for an Atlas project, see Configure Atlas API Access.

Syntax

GET /api/atlas/v1.0/groups/{GROUP-ID}/databaseUsers/{databaseName}/{USERNAME}

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required. Unique identifier for the project.
databaseName Required.

The user’s authentication database.

Accepted values include:

  • $external if the user is authenticated using X.509 certificates or LDAP.

  • admin users authenticated using SCRAM-SHA.

    This is the default authentication scheme in Atlas.

USERNAME Required.

Username to retrieve.

Must be a fully qualified distinguished name, as defined in RFC 2253, if:

  • ldapAuthType is USER or GROUP, or
  • x509Type is CUSTOMER.

Request Query Parameters

The following query parameters are optional:

Query Parameter Type Description Default
pretty boolean Displays response in a prettyprint format. false
envelope boolean Specifies whether or not to wrap the response in an envelope. false

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

If you set the query element envelope to true, the response is wrapped by the content object.

Response Element Type Description
databaseName string

The user’s authentication database. A user must provide both a username and authentication database to log into MongoDB.

Returned values include:

  • $external if the user is authenticated using X.509 certificates or LDAP.

  • admin users authenticated using SCRAM-SHA.

    This is the default authentication scheme in Atlas.

deleteAfterDate string Timestamp in ISO 8601 date and time format in UTC after which Atlas deletes the user. This field is only present if an expiration date was specified when creating the entry.
groupId string Unique identifier of the Atlas project to which the user belongs.
labels array of documents Array containing key-value pairs that tag and categorize the database user.
ldapAuthType string

Method by which the specified username is authenticated. If no value is given, Atlas uses the default value of NONE.

Returned values include:

NONE Atlas authenticates this user through SCRAM-SHA, not LDAP.
USER LDAP server authenticates this user through the user’s LDAP user.
GROUP LDAP server authenticates this user using their LDAP user and authorizes this user using their LDAP group. To learn more about LDAP security, see Set up User Authentication and Authorization with LDAP.
x509Type string

X.509 method by which the provided username is authenticated. If no value is given, Atlas uses the default value of NONE.

The possible types are:

NONE The user does not use X.509 authentication.
MANAGED

The user is being created for use with Atlas-managed X.509.

Externally authenticated users can only be created on the $external database.

CUSTOMER

The user is being created for use with Self-Managed X.509. Users created with this x509Type require a Common Name (CN) in the username field. To learn more, see RFC 2253.

Externally authenticated users can only be created on the $external database.

links document array One or more links to sub-resources and/or related resources.
roles string array Array of this user’s roles and the databases / collections on which the roles apply. A role allows the user to perform particular actions on the specified database. A role on the admin database can include privileges that apply to the other databases as well.
roles
.collectionName
string Collection on which the user has the specified role.
roles
.databaseName
string Database on which the user has the specified role. A role on the admin database can include privileges that apply to the other databases.
roles
.roleName
string

Name of the role. The accepted values are:

username string

Username for authenticating to MongoDB.

A fully qualified distinguished name, as defined in RFC 2253, is returned if:

  • ldapAuthType is USER or GROUP, or
  • x509Type is CUSTOMER.

Examples

Request

Retrieve one database user that Atlas authenticates using SCRAM-SHA and the admin database.

Important

You must modify the following code block with the appropriate credentials and project ID.

curl -i -u "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/5356823b3794dee37132bb7b/databaseUsers/admin/ellen"

Retrieve one database user that Atlas authenticates using X.509 or LDAP and the $external database.

Important

You must modify the following code block with the appropriate credentials and project ID.

curl -i -u "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/5356823b3794dee37132bb7b/databaseUsers/$external/CN=ellen@example.com,OU=users,DC=example,DC=com"

Response Header

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=ISO-8859-1
Date: {dateInUnixFormat}
WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false
Content-Length: {requestLengthInBytes}
Connection: keep-alive
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Type: application/json
Strict-Transport-Security: max-age=300
Date: {dateInUnixFormat}
Connection: keep-alive
Content-Length: {requestLengthInBytes}

Response Body

{
  "databaseName" : "admin",
  "groupId" : "5356823b3794dee37132bb7b",
  "links" : [ ... ],
  "labels": [],
  "roles" : [ {
    "databaseName" : "admin",
    "roleName" : "readAnyDatabase"
  }, {
    "databaseName" : "marketing",
    "roleName" : "readWrite"
  }, {
    "databaseName" : "marketing",
    "roleName" : "backup"
  } ],
  "username" : "ellen"
}
{
  "databaseName" : "$external",
  "groupId" : "5356823b3794dee37132bb7b",
  "links" : [ ... ],
  "labels": [],
  "roles" : [ {
    "databaseName" : "admin",
    "roleName" : "readAnyDatabase"
  }, {
    "databaseName" : "marketing",
    "roleName" : "readWrite"
  }, {
    "databaseName" : "marketing",
    "roleName" : "backup"
  } ],
  "username" : "CN=ellen@example.com,OU=users,DC=example,DC=com"
}