databasemongodbbackendmongodb-atlas

MongoDB Atlas CMD_NOT_ALLOWED: grantRolesToUser and dropDatabase Permissions Issue


I am encountering issues with MongoDB Atlas permissions while trying to manage user roles and perform administrative actions. Specifically, I am facing the following errors:

MongoServerError[AtlasError]: CMD_NOT_ALLOWED: grantRolesToUser MongoServerError[AtlasError]: user is not allowed to do action [dropDatabase] on [test]

Problem: When attempting to use the grantRolesToUser command in MongoDB Atlas, I receive a CMD_NOT_ALLOWED error. Similarly, I am unable to execute dropDatabase due to permission restrictions.

Context: I am using MongoDB Atlas as my managed database service. I have administrative privileges in the Atlas project but seem to be restricted from executing these commands.

Permissions Granted: I have granted readWrite privileges for the user in MongoDB Atlas, specifically on certain databases.

Steps Taken:

I have verified that my user account has administrative roles within the Atlas project. I attempted to modify user roles and permissions through both MongoDB shell (mongo) and MongoDB Atlas dashboard (https://cloud.mongodb.com), but encountered the same permission issues.

Expected Outcome:

I expect to be able to manage user roles (grantRolesToUser) and perform administrative actions like dropDatabase without encountering permission errors.


Solution

  • Commands like grantRolesToUser are not supported on MongoDB Atlas, see Unsupported Commands in Atlas.

    When you use Atlas, then user and roles are managed in the Atlas UI or Atlas CLI or Atlas Administration API, see Configure Database Users