MongoDB Questions and Answers – Collection-Level Access Control

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Collection-Level Access Control”.

1. Administrators can implement collection-level access control through user-defined __________
a) roles
b) replica sets
c) shards
d) none of the mentioned
View Answer

Answer: a
Explanation: By creating a role with privileges that are scoped to a specific collection in a particular database, administrators can provision users with roles that grant privileges on a collection level.

2. Point out the correct statement.
a) A rule consists of actions and the resources upon which the actions are permissible
b) Document-level access control allows developers to grant users privileges that are scoped to specific record
c) Each privilege action in a role can be scoped to a different record
d) None of the mentioned
View Answer

Answer: b
Explanation: Collection-level access control allows administrators to grant users privileges that are scoped to specific collections.

3. User can grant any role in the database to any user from any database in the system through _________ action.
a) grantRole
b) viewRole
c) killCursors
d) unlock
View Answer

Answer: a
Explanation: Apply this action to database resources.

advertisement
advertisement

4. User can remove any role from any user from any database in the system through _________
a) grantRole
b) viewRole
c) killCursors
d) revokeRole
View Answer

Answer: d
Explanation: User can view information about any role in the given database through viewRole.

5. Point out the wrong statement.
a) MongoDB uses the combination of the database name and the role name to uniquely define a role
b) A role consists of privileges that pair resources with not allowed operations
c) Roles grant users access to MongoDB resources
d) None of the mentioned
View Answer

Answer: d
Explanation: Except for roles created in the admin database, a role can only include privileges that apply to its database and can only inherit from other roles in its database.

6. _________ terminates an operation as specified by the operation ID.
a) db.killOp()
b) db.kill()
c) db.remove()
d) none of the mentioned
View Answer

Answer: a
Explanation: Only use db.killOp() to terminate operations initiated by clients and do not terminate internal database operations.

7. Which of the following allows the user to view the information of any user in the given database?
a) createUser
b) viewUser
c) killCursors
d) all of the mentioned
View Answer

Answer: b
Explanation: To provide user administrators, MongoDB has userAdmin and userAdminAnyDatabase roles.

advertisement

8. _________ deletes from a shard the orphaned documents whose shard key values fall into a single continuous range.
a) listallshards
b) cleanup
c) cleanupOrphaned
d) SelectIndexes
View Answer

Answer: c
Explanation: If two contiguous ranges do not belong to the shard, the cleanupOrphaned examines both ranges for orphaned documents.

9. Which of the following flushes user information from in-memory cache?
a) grantCache
b) invalidateUserCache
c) validateUserCache
d) none of the mentioned
View Answer

Answer: b
Explanation: invalidateUserCache allows you to purge the cache at any given moment, regardless of the interval set in the userCacheInvalidationIntervalSecs parameter.

advertisement

10. __________ displays the cached query plans for the specified query shape.
a) CacheListPlans
b) displayCacheListPlans
c) planCacheListPlans
d) none of the mentioned
View Answer

Answer: b
Explanation: The query optimizer only caches the plans for those query shapes that can have more than one viable plan.

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.