MongoDB DBA · Question 518 · Single choice

36. 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("daniel", { "showActions": true} )
  3. C.
    db.getUser("userAdminAnyDatabase", { "showPrivileges": true} )
  4. D.
    db.getRole("userAdminAnyDatabase", { "showPrivileges": true} )
  5. E.
    db.getUser("daniel", { "showActions": true} )

Answer confidence: Medium

Correct answer: D

Explanation language: Chinese

要查看某个角色包含哪些权限/动作,用 db.getRole(<角色名>, { "showPrivileges": true });用户 daniel 的角色是 userAdminAnyDatabase,所以命令是 D,返回结果中的 privileges 会列出各资源上的 actions。C 把角色名当用户名传给 getUser,E 的 showActions 不是 getUser 支持的选项,B 又把用户名 daniel 当成角色名,都是错的。

Papers containing this question

This question appears in 1 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 ↗