对于 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

User's authentication information. For users with externally stored authentication credentials, such as users that use Kerberos or X.509 certificates for authentication, the system.users document for that user does not contain the credentials field. For SCRAM user credentials, the information includes the mechanism, iteration count, and authentication parameters.

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 数据库。Kari 在 home 数据库中具有 read 角色,在 test 数据库中具有 readWrite 角色。

给本页内容打分