- Security >
- Security Tutorials >
- User and Role Management Tutorials >
- View Roles
View Roles¶
On this page
Overview¶
A role grants privileges to the users who are assigned the
role. Each role is scoped to a particular database, but MongoDB stores all
role information in the admin.system.roles
collection in the
admin
database.
Prerequisites¶
To view a role’s information, you must be explicitly granted the
role or must have the viewRole
action on the role’s database.
Procedures¶
The following procedures use the rolesInfo
command. You also
can use the methods db.getRole()
(singular) and
db.getRoles()
.
View a Role in the Current Database¶
If the role is in the current database, you can refer to the role
by name, as for the role dataEntry
on the current database:
View a Role in a Different Database¶
If the role is in a different database, specify the role as a document. Use the following form:
To view the custom appWriter
role in the orders
database, issue the following command from the mongo
shell:
View Multiple Roles¶
To view information for multiple roles, specify each role as a document or string in an array.
To view the custom appWriter
and clientWriter
roles
in the orders
database, as well as the dataEntry
role on the
current database, use the following command from the mongo
shell:
View All Custom Roles¶
To view the all custom roles, query admin.system.roles collection directly, for example: