28. Consider the following existing user definition: use admin db.getUser('yulia') { "_id": "products.yulia", "user": "yulia", "db": "products", "roles": [ { "role": "dbAdmin", "db": "products" } ], ... ] } Which of the following commands would allow the user yulia to become a system administrator on the locations database? (assume you are running all commands as a root level user and have permissions to run all commands) Check all that apply:
题目选项
- A.db.createUser({ "user": "yulia", "pwd": "***", "roles": [{"db":"*", "role": "dbAdmin"}] })
- B.db.updateUser("yulia", {"roles": [{"db":"admin", "role": "dbAdminAnyDatabase"}]})
- C.db.updateUser("yulia", {"roles": [{"db":"locations", "role": "dbAdmin"}]})
答案置信度:中
正确答案:B、C
解析语言:中文
A 不可行:yulia 已存在,createUser 会因用户重名失败,而且角色文档里 db:"*" 也不是合法写法(跨库要用 dbAdminAnyDatabase 这类角色名)。B 用 updateUser 把角色替换为 dbAdminAnyDatabase(覆盖 locations),C 直接授予 locations 上的 dbAdmin,两者都能让 yulia 在 locations 上获得管理员权限。