aboutsummaryrefslogtreecommitdiff
path: root/databases/mongo/admins.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-05-06 21:31:46 -0500
committerGitHub <noreply@github.com>2025-05-06 21:31:46 -0500
commit95bf612c338dec8235e89ca6a1d9e5e8cad3f997 (patch)
tree82cfd62fb145b7b686d4ae825ab2c2436343e590 /databases/mongo/admins.py
parentd62f25007470fe546e0f9d2e38a26e84146f72c5 (diff)
downloadaudit-tools-95bf612c338dec8235e89ca6a1d9e5e8cad3f997.tar.gz
audit-tools-95bf612c338dec8235e89ca6a1d9e5e8cad3f997.tar.bz2
audit-tools-95bf612c338dec8235e89ca6a1d9e5e8cad3f997.zip
reorganize db dir (#6)
Diffstat (limited to 'databases/mongo/admins.py')
-rw-r--r--databases/mongo/admins.py16
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)