我需要列出所有可以通过 PHP 访问 MongoDB 的用户。基本上与您从 mongo shell 执行以下操作相同:
> use test
switched to db test
> show users
{
"_id" : ObjectId("51f74b1c9d8036288ae01e98"),
"user" : "admin",
"pwd" : "cc4fa5214a55925052f2892be6feb470",
"roles" : [
"readWrite",
"dbAdmin"
]
}
{
"_id" : ObjectId("52085c1dc9f60326cb20cb37"),
"user" : "user_name",
"pwd" : "ec416be9a5e17fbe48a7ceb93e63ecba",
"roles" : [
"readWrite",
"dbAdmin"
]
}
{
"_id" : ObjectId("52085c35c9f60326cb20cb38"),
"user" : "test_user",
"pwd" : "bf7a0adf9822a3379d6dfb1ebd38b92e",
"roles" : [
"readWrite"
]
}
我尝试过使用 PHP 内置的执行命令,但没有任何运气。有人有想法么?