diff --git a/source/core/security-users.txt b/source/core/security-users.txt index cea3991ac0c..4ac929a0021 100644 --- a/source/core/security-users.txt +++ b/source/core/security-users.txt @@ -142,3 +142,4 @@ general, clients should connect to the sharded cluster through the /tutorial/create-users /tutorial/authenticate-a-user + /tutorial/list-users diff --git a/source/tutorial/list-users.txt b/source/tutorial/list-users.txt new file mode 100644 index 00000000000..622ced8fcdb --- /dev/null +++ b/source/tutorial/list-users.txt @@ -0,0 +1,42 @@ +.. _list-users: + +========== +List Users +========== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 3 + :class: singlecol + +To list all users, use :binary:`~bin.mongosh` to query the +:doc:`system.users ` collection: + +.. code-block:: sh + + use admin + db.system.users.find() + +.. important:: + + Do not modify the :doc:`system.users + ` collection directly. To manage + users, use the designated :ref:`user management commands + `. + +To list all users of a :doc:`sharded cluster ` that were +created through a :binary:`~bin.mongos`, connect to a +:binary:`~bin.mongos` and run the preceding command. MongoDB stores +users that are created through a :binary:`~bin.mongos` in the ``admin`` +database of the :term:`config servers `. + +To list all :ref:`shard local users +`, connect to the respective shard directly and run +the preceding command. MongoDB stores *shard local* users in the +``admin`` database of the shard itself. These *shard local* users are +independent from the users added to the sharded cluster through a +:binary:`~bin.mongos`. *Shard local* users are local to the shard and +are inaccessible to :binary:`~bin.mongos`.