MongoDB Questions and Answers – User and Role Management

«
»

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

Answer: b
Explanation: The localhost exception allows you to enable authorization before creating the first user in the system.

advertisement

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

Answer: d
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

Answer: b
Explanation: If the user requires additional privileges, grant to the user the role, or roles, with the required set of privileges.

advertisement
advertisement

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

Answer: c
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

Answer: a
Explanation: You can use –noauth option when starting mongod to gain full access the system.

advertisement

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

Answer: c
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

Answer: c
Explanation: User can remove any role from any user from any database in the system.

advertisement

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

Answer: b
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

Answer: a
Explanation: You can use the openssl program to generate unique strings for use in passwords, as in the following command: openssl rand -base64 48

advertisement

10. The ________ field contains optional custom information about the user.
a) customDataAll
b) OptmData
c) customData
d) all of the mentioned
View Answer

Answer: c
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 Reference Books in MongoDB.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter