On this page
db.getUser()
在本页面
Definition
db.
getUser
(用户名,* args *)- 返回指定用户的用户信息。在用户的数据库上运行此方法。用户必须存在于运行该方法的数据库上。
db.getUser()方法具有以下参数:
Parameter | Type | Description |
---|---|---|
username |
string | 要为其检索信息的用户的名称。 |
args |
document | 可选的。指定其他参数的文档。 |
args
文档支持以下字段:
Field | Type | Description |
---|---|---|
showCredentials |
boolean | 可选的。将字段设置为 true 以显示用户的密码哈希。默认情况下,此字段为false 。 |
showPrivileges |
boolean | 可选的。将字段设置为 true 以显示用户的完整特权集,包括继承角色的扩展信息。默认情况下,此字段为false 。如果查看所有用户,则不能指定此字段。 |
showAuthenticationRestrictions |
boolean | 可选的。将字段设置为 true 以显示用户的身份验证限制。默认情况下,此字段为false 。如果查看所有用户,则不能指定此字段。 |
Required Access
要查看另一个用户的信息,您必须在另一个用户的数据库上拥有viewUser action。
用户可以查看自己的信息。
Example
以下操作序列返回有关accounts
数据库上的appClient
用户的信息:
use accounts
db.getUser("appClient")