Navigation
This version has reached end of life on October 2016. Learn more about upgrading your version of MongoDB.

db.getUser()

Definition

db.getUser(username)

Returns user information for a specified user. Run this method on the user’s database. The user must exist on the database on which the method runs.

The db.getUser() method has the following parameter:

Parameter Type Description
username string The name of the user for which to retrieve information.

db.getUser() wraps the usersInfo command.

Required Access

You must have the viewUser action on another user’s database to view the other user’s credentials.

You can view your own information.

Example

The following sequence of operations returns information about the appClient user on the accounts database:

use accounts
db.getUser("appClient")