This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “User and Role Management”.
1. To view a role’s information, you must be explicitly granted the role or must have the _________ action on the role’s database.
a) viewUser
b) viewRole
c) grantRole
d) none of the mentioned
View Answer
Explanation: The localhost exception allows you to enable authorization before creating the first user in the system.
2. Point out the correct statement.
a) To provide user administrators, MongoDB has userAdmin and userAdminAnyDatabase roles
b) A user administrator can grant any privilege in the database and can create new ones
c) Specifically, a user with the userAdmin role can grant itself any privilege in the database
d) All of the mentioned
View Answer
Explanation: A user assigned either the userAdmin role on the admin database or the userAdminAnyDatabase can grant itself any privilege in the system.
3. Grant the user the role using the ________ method.
a) db.grantRole()
b) db.grantRolesToUser()
c) db.grantToUser()
d) all of the mentioned
View Answer
Explanation: If the user requires additional privileges, grant to the user the role, or roles, with the required set of privileges.
4. Which of the following method is used to identify the privileges granted by the roles?
a) rolesUser
b) rolesInfo
c) rolesView
d) all of the mentioned
View Answer
Explanation: db.getRole() wraps the rolesInfo command.
5. Point out the wrong statement.
a) You must have the createUser action on a database to create a new user on that database
b) You must have the grantRole action on a role’s database to grant the role to another user
c) If your MongoDB deployment has no users, you must connect to mongod using the localhost exception
d) None of the mentioned
View Answer
Explanation: You can use –noauth option when starting mongod to gain full access the system.
6. ____________ removes a one or more roles from a user on the current database.
a) db.revokeRolesUser()
b) db.revokeRoles()
c) db.revokeRolesFromUser()
d) none of the mentioned
View Answer
Explanation: To specify a role that exists in the same database where db.revokeRolesFromUser() runs, you can either specify the role with the name of the role.
7. You must have the __________ action on a database to revoke a role on that database.
a) revokePrivelege
b) revokeUser
c) revokeRole
d) all of the mentioned
View Answer
Explanation: User can remove any role from any user from any database in the system.
8. You must have the _________ action on a database to modify the password of any user on that database.
a) changePassword
b) changeAnyPassword
c) removePassword
d) none of the mentioned
View Answer
Explanation: To change your own password, you must have the changeOwnPassword action on your database.
9. Which of the following can be used to generate unique strings for use in passwords?
a) openssl
b) openssd
c) oppstringpwd
d) none of the mentioned
View Answer
Explanation: You can use the openssl program to generate unique strings for use in passwords, as in the following command: openssl rand -base64 48
10. The ________ field contains optional custom information about the user.
a) customDataAll
b) OptmData
c) customData
d) all of the mentioned
View Answer
Explanation: The system.users collection in the admin database stores user authentication and authorization information.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check MongoDB Books
- Apply for Programming Internship
- Check Information Technology Books
- Practice Programming MCQs