diff options
Diffstat (limited to 'databases/mongo/admins.py')
-rw-r--r-- | databases/mongo/admins.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/databases/mongo/admins.py b/databases/mongo/admins.py new file mode 100644 index 0000000..e844cbc --- /dev/null +++ b/databases/mongo/admins.py @@ -0,0 +1,16 @@ +from pymongo import MongoClient
+
+# Connect to the MongoDB server
+client = MongoClient("mongodb://localhost:27017/")
+
+# Select the 'admin' database
+db = client.admin
+
+# Query the 'system.users' collection
+users = db.system.users.find(
+ {}, {"user": 1, "db": 1, "roles": 1, "credentials": 1, "userSource": 1}
+)
+
+# Print the results in a pretty format
+for user in users:
+ print(user)
|