0

I have a MongoDB user created into admin database

When i try to use some functions (from mongoDB native driver in nodeJs) it throws an error:

{ name: 'MongoError', message: 'not authorized on stop to execute command { findandmodify: "users", query: { _id: 1 }, new: true, remove: false, upsert: true, update: {...

{
    "_id" : "admin.admin",
    "user" : "admin",
    "db" : "admin",
    "credentials" : {
        "SCRAM-SHA-1" : {
            "iterationCount" : 10000,
            "salt" : "xxxx",
            "storedKey" : "xxxx",
            "serverKey" : "xxxx"
        }
    },
    "roles" : [ 
        {
            "role" : "root",
            "db" : "admin"
        }, 
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }, 
        {
            "role" : "readWriteAnyDatabase",
            "db" : "admin"
        }, 
        {
            "role" : "dbOwner",
            "db" : "admin"
        }, 
        {
            "role" : "clusterAdmin",
            "db" : "admin"
        }
    ]
}

Any other commands like find or update works.

I want this user to be a SUPER USER but I have assigned it all type of roles, but none of them works, i tried root, adminAnyDatabase, etc.

I'm using mongodb 3.0.9

Any idea how to solve this? Which permision do i need to allow findAndModify command?

4
  • After some digging, i restarted my mongodb server and all started working as expected. Is there a way to "delete" this question?
    – Pipe
    Feb 18, 2016 at 17:14
  • 2
    You should be able to delete it. However, you can put your solution as an answer, because it might help others. A side note: NEVER use an admin user for data access. Create a specialized user with as few privileges as possible to get the job done. Feb 23, 2016 at 13:51
  • I wanted to add (for others reading this) that You should check the node driver version too, because I was trying to use an older version of the driver and it was failing with the same error. Check the URI too (older versions use a different schema)
    – Skaparate
    Nov 3, 2019 at 16:38
  • I don't know what the error was... I only restarted mongodb server, and it started working... maybe it needed some "flush privileges" operation?
    – Pipe
    Nov 7, 2019 at 19:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.