db.getUsers() can show all users in current database in mongodb, but how to list all users in all databases for ease of management as an administrator? I have tried to check if there is any collection under "admin" database where it contains users authentication and authorization but it has none. Please note that this is test environment but i have created users in admin database. Not sure why "system.users " collection is not showing up under "admin" database.Hi Sharmila,
Not sure why “system.users “ collection is not showing up under “admin” database.
This was actually a known issue that is being addressed in SERVER-38867.
You can list all users in all databases by using a script in the mongo shell, for example:
Mongo().getDBNames().forEach( x => { Mongo().getDB(x).getCollection('system.users').find().forEach(printjson) })
Also,how can we check how many users are logged in currently
I don’t believe there’s a function to list the number of logged in users. However, you can check the current number of connections to the server using the db.serverStatus().connections command, the output of which is explained in the serverStatus page
Best regards,
Kevin
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/PcjFqSGYH9s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/44465b45-bdbc-4bff-9d4e-2c58148469bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.