MongoDB DBA · Question 153 · Single choice

37. Consider the following user: { "_id" : "admin.daniel", "user" : "daniel", "db" : "admin", "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ], "mechanisms" : [ "SCRAM-SHA-1", "SCRAM-SHA-256" ] } Which command, when run against the admin database, would list the actions possible for this user? Choose the best answer:

Answer options

  1. A.
    > db.getUser("userAdminAnyDatabase")
  2. B.
    > db.getRole("userAdminAnyDatabase", { "showPrivileges": true} )
  3. C.
    > db.getRole("daniel", { "showActions": true} )
  4. D.
    > db.getUser("daniel", { "showActions": true} )
  5. E.
    > db.getUser("userAdminAnyDatabase", { "showPrivileges": true} )

Answer confidence: High

Correct answer: B

Explanation language: Chinese

db.getRole(<角色名>, { showPrivileges: true }) 会列出该角色(含继承)的全部权限及对应动作,故 B 正确。getUser 只返回用户及其角色定义,不接受 showActions/showPrivileges 这类参数(A、D 错),C 用了不存在的 showActions,E 则把角色名写成了不匹配的参数。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗