Hi Team ,
There is a requirement of generating DDL statements for users and roles that are already existing in the environment .
Required your help if there are any kind of customise scripts that I can run from mongo Shell to get the DDL of existing users and roles.
Welcome back to the MongoDB Community forums
Can you please clarify the above statement or provide additional details about your specific requirements?
However, if I understand your question correctly, you are looking for a way to obtain a list of all the database users with their roles. You can achieve this by using the
db.getUsers() command in the MongoDB Shell. This command retrieves the necessary details you need. Make sure you have the appropriate privileges, specifically the
viewUser action, to access the information of other users in their respective databases. You can find more details about this command and its usage in the MongoDB documentation on
I hope this information helps! If you have any further questions or need further assistance, please feel free to reach out.