1

I have a database in mongoDB 2.6.4 in which I want to restrict the users as per their level. I want to give read privileges to some users and insert/update privileges to some other users on a particular database. Please let me know how I can create user defined roles and assign them to the users. I tried the below but it is not working; the users still have full privileges:

db.runCommand({createRole: "read",

   privileges: [

         { resource: { db: "sample", collection: "" }, 
                     actions: [ "find" ] 
           }],
   roles: [],

   writeConcern: { w: "majority" , wtimeout: 5000 }

             })

==================================================================================

db.addUser( { user : "read",
              pwd  : "read",
              roles:["read"]
        } )
  • Are the users members of other roles in addition to read? – LowlyDBA Dec 30 '14 at 14:36
  • Yes ,we need to provide some user only ready on the database and some user can run CURD operation on a particular database. – user2589918 Dec 30 '14 at 14:49
  • I meant that you should check to make sure that the users don't have other roles which are granting privileges above just read from the read role. – LowlyDBA Dec 30 '14 at 14:51
  • I got that but the user have the below privileges in the read roles "actions" : [ "collStats", "dbHash", "dbStats", "find", "killCursors", "planCacheRead" – user2589918 Dec 30 '14 at 15:17
  • but still the user who have read privileges able to create the database as well drop – user2589918 Dec 30 '14 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.