对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

system.users 自管理部署中的集合

admin 数据库的 system.users 集合存储用户身份验证授权信息。为了管理该集合中的数据,MongoDB 提供了用户管理命令

system.users 集合中的文档具有以下模式:

{
_id: <system defined id>,
userId : <system assigned UUID>,
user: "<name>",
db: "<database>",
credentials: { <authentication credentials> },
roles: [
{ role: "<role name>", db: "<database>" },
...
],
customData: <custom information>,
authenticationRestrictions : [ <documents> ]
}

每个 system.users 文档包含以下字段:

admin.system.users.userId

创建时分配给用户的唯一标识符。

admin.system.users.user

The user name. A user exists in the context of a single logical database (see admin.system.users.db) but can have access on other databases through roles specified in the roles array.

admin.system.users.db

The authentication database associated with the user. The user's privileges are not necessarily limited to this database. The user can have privileges in additional databases through the roles array.

admin.system.users.credentials

用户的身份验证信息。对于具有外部存储的身份验证凭证的用户,例如使用Kerberos或 X.509 证书进行身份验证的用户,该用户的system.users 文档不包含credentials 字段。对于SCRAM用户凭证,信息包括机制、迭代计数和身份验证参数。

admin.system.users.roles

授予用户的角色数组。该数组包含内置角色用户定义的角色。

角色文档的语法如下:

{ role: "<role name>", db: "<database>" }

角色文档包含以下字段:

admin.system.users.roles[n].role

角色的名称。角色可以是 MongoDB 提供的内置角色用户定义的自定义角色。

admin.system.users.roles[n].db

定义角色的数据库名称。

使用角色管理用户管理命令指定角色时,如果运行该命令的数据库上存在该角色,则可单独指定角色名称(例如 "readWrite")。

admin.system.users.customData

有关用户的可选自定义信息。

admin.system.users.authenticationRestrictions

服务器对用户实施的一个身份验证限制数组。该数组包括 IP 地址和 CIDR 范围列表,允许这些地址和范围的用户连接至服务器或者服务器接受这些用户。

system.users 集合中的以下文档为例:

{
"_id" : "home.Kari",
"userId" : UUID("ec1eced7-055a-4ca8-8737-60dd02c52793"),
"user" : "Kari",
"db" : "home",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "S/xM2yXFosynbCu4GzFDgQ==",
"storedKey" : "Ist4cgpEd1vTbnRnQLdobgmOsBA=",
"serverKey" : "e/0DyzS6GPboAA2YNBkGYm87+cg="
},
"SCRAM-SHA-256" : {
"iterationCount" : 15000,
"salt" : "p1G+fZadAeYAbECN8F/6TMzXGYWBaZ3DtWM0ig==",
"storedKey" : "LEgLOqZQmkGhd0owm/+6V7VdJUYJcXBhPUvi9z+GBfk=",
"serverKey" : "JKfnkVv9iXwxyc8JaapKVwLPy6SfnmB8gMb1Pr15T+s="
}
},
"authenticationRestrictions" : [
{ "clientSource" : [ "69.89.31.226" ], "serverAddress" : [ "172.16.254.1" ] }
],
"customData" : {
"zipCode" : "64157"
},
"roles" : [
{
"role" : "read",
"db" : "home"
},
{
"role" : "readWrite",
"db" : "test"
}
]
}

文档显示,用户 Kari 的身份验证数据库是 home 数据库。Karihome 数据库中具有 read 角色,在 test 数据库中具有 readWrite 角色。

给本页内容打分