custom-role - MongoDB Enterprise

30 views
Skip to first unread message

Raj Rajadurai

unread,
Jan 22, 2017, 7:50:04 PM1/22/17
to mongodb-user
I am trying to create a custom role and I am getting the following error: Not able to figure out what is the correct syntax to create the role. I tried use "admin" and "use HR" to try from both the DBs. Can someone help with the correct syntax?


MongoDB Enterprise>db.createRole ( { role: 'HRDEPARTMENT',

privileges: [ { resource: { db: 'HR', collection: '' } , actions: [ "find" ] } , {resource: {db: 'HR', collection: 'employees' }, actions: ["insert"] } ],

roles:  [ { role: 'dropUser', db: 'HR'}

]

 } )


Error: Cannot grant nonexistent role dropUser@HR :



Wan Bachtiar

unread,
Jan 25, 2017, 12:05:21 AM1/25/17
to mongodb-user

Error: Cannot grant nonexistent role dropUser@HR :

Hi Raj,

As specified on the manual for createRole(), the roles field should contain a role to inherit privileges from. According to the error log that you are seeing, there is no role with name dropUser.

If you are attempting to inherit from the built-in roles , dropUser is a privilege action not a role.

MongoDB Enterprise>db.createRole

Note that the MongoDB Enterprise edition is a commercially supported product. If your company already has a commercial subscription I would suggest to open a case in the Commercial Support Portal.

Alternatively if you are evaluating MongoDB Enterprise and interested, send me a private message with your contact details and I can request a MongoDB Account Executive to reach out to you.

Kind regards,

Wan.

Reply all
Reply to author
Forward
0 new messages