June 2014
Intermediate to advanced
696 pages
38h 52m
English
User accounts are stored in the db.system.users collection of each database. The User object contains _id, user, pwd, roles, and sometimes otherDBRoles fields. There are a couple different ways to get a list of user objects. The first is to change the database to the one you want to list users on and then execute the show users command. The following example changes to the admin database and lists users as shown in Figure 12.3:
use adminshow users
Figure 12.3 Listing users on the admin database.
You can also use a query such as find on the db.system.users collection. However, db.system.users.find() returns a cursor object that you ...
Read now
Unlock full access