Eval script not working mongodb 3.0.2 with "dbOwner" role

493 views
Skip to first unread message

Soorya Prakash

unread,
May 28, 2015, 6:38:37 AM5/28/15
to mongod...@googlegroups.com
Hi,
  I have upgraded my mongo db 2.4.10 to 2.6 and i run the following commands.

            db.upgradeCheckAllDBs();
            db.adminCommand({authSchemaUpgrade: 1 });


After that i again upgrade my db to 3.0.2 and mongo process running with auth enabled. I am already having few dbs with  user with role as "dbOwner". But using that user I am not able to run the eval script from the mongo shell. I am getting error while running the eval script from the db "abc" after  authenticated with db.auth() command.

Unauthorized not authorized on abc to execute command { $eval: "deleteInfoDetails()" }

I am using the same user as the dbOwner for multiple databases. What kind of role should i add to support in eval script in multiple databases.  And also i am using node js mongodb library version 2.0.33. when i execute the code like below not running.
 db.open(function(err,result) {
         // the db.admin not working
            db.admin(function(err,admindb) {
});
});

 Can anyone help to solve this problem?



 



davidmo

unread,
May 28, 2015, 12:49:09 PM5/28/15
to mongod...@googlegroups.com
$EVAL has been deprecated since 3.0

Stephen Steneker

unread,
May 28, 2015, 2:12:10 PM5/28/15
to mongod...@googlegroups.com, sooryapr...@gmail.com
On Thursday, 28 May 2015 03:38:37 UTC-7, Soorya Prakash wrote:
  I have upgraded my mongo db 2.4.10 to 2.6 and i run the following commands.

            db.upgradeCheckAllDBs();
            db.adminCommand({authSchemaUpgrade: 1 });


After that i again upgrade my db to 3.0.2 and mongo process running with auth enabled. I am already having few dbs with  user with role as "dbOwner". But using that user I am not able to run the eval script from the mongo shell. I am getting error while running the eval script from the db "abc" after  authenticated with db.auth() command.

Unauthorized not authorized on abc to execute command { $eval: "deleteInfoDetails()" }

Hi Soorya,

To run $eval in MongoDB 2.6+ you need to create a custom role that grants anyAction on anyResource:

As someone else has already noted .. use of $eval has been deprecated as of MongoDB 3.0. While the command is still available, it is planned for removal in an upcoming release and you should consider an alternative approach for future compatibility. For more background see: https://jira.mongodb.org/browse/SERVER-17453.

Regards,
Stephen

Soorya Prakash

unread,
May 29, 2015, 1:35:20 AM5/29/15
to mongod...@googlegroups.com
Then what is the alternative approach to run the server-side scripts to run from the node js, java and also in mongo shell where the scripts are stored in system.js collection.

Soorya Prakash

unread,
May 29, 2015, 2:38:14 AM5/29/15
to mongod...@googlegroups.com
In mongodb 3.0.2 , from admin I created the role like below

db.createRole({
    "role" : "superAdmin",
    "privileges" : [
        {
            "resource" : {
                "anyResource" : true
            },
            "actions" : [
                "anyAction"
            ]
        }
    ],
    "roles" : [ ]
})
 and then i add new user as with the "admin" db.
db.createUser({
    user: 'admin',
    pwd: 'admin123',
    roles: ['superAdmin']
})

So this means the user is belongs to only "admin" db right?. If I want to assign the same role to other db , how can i do it?. Because in my application I directly access the db other than the "admin" db with user having role as "dbOwner".In that I am running the eval script via java and also in node js.So, how can i achieve that?

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/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/1zfCGq3e_Dw/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 http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/12951f91-fe0d-4bec-9ee4-5dc987e099cb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages