2

After updating my DB version from 2.2 to 2.4 I've found that I couldn't execute Database.Eval() function from my C# code because "I don't have permissions to perform my task". After some investigation I've discovered that there were some changes in MongoDB:

With authentication enabled, db.eval() will fail during the operation if you do not have the permission to perform a specified task. Changed in version 2.4: You must have full admin access to run.

http://docs.mongodb.org/manual/reference/method/db.eval/

Can you advise me on how to specify those admin rights in my C# code?

Update 1: I didn't mention that I'm using login:password at the start of my connection string and the user is in the following roles: roles: [ "readWrite", "dbAdmin" ] } I'm also using the MongoHQ db hosting.

1
  • After setting up a user that has admin rights, you can append the username and password to the connection string like so var connectionString = "mongodb://admin:password@localhost". Commented Jan 23, 2014 at 21:54

1 Answer 1

1

You have to add the righst (dbAdmin role, userAdmin role, clusterAdmin role) to your connection string user.

1- check your user on the connection string

mongodb://[username:password@]host1[:port1]...

2- Create the user with the admin role db.addUser( { user: "<user>", pwd: "<password>", roles: [<roles>] } )

see http://docs.mongodb.org/manual/reference/user-privileges/ http://docs.mongodb.org/manual/reference/method/db.addUser/

Sign up to request clarification or add additional context in comments.

1 Comment

Please see the Update 1

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.