Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to display current user in MongoDB

Question: I jump around on various Mongodb databases and want to create  a process to programatically check the  Current USER. What is the MongoDB command to check the current user?

Answer:

Adding the connectionStatus details will give you formation about the current connection, specifically the state of authenticated users and their available permissions.

db.runCommand({connectionStatus : 1})

If you want to return extra information about the privileges , you can add the showPrivileges parameter, which will list out all the user privileges.

db.runCommand({connectionStatus : 1,showPrivileges:true})

Read more about MongoDB 

Quick Access To Mongodb Commands Cheat Sheet -



This post first appeared on Dba-ninja.com, please read the originial post: here

Share the post

How to display current user in MongoDB

×

Subscribe to Dba-ninja.com

Get updates delivered right to your inbox!

Thank you for your subscription

×