MongoServerError[Unauthorized]: admin user cannot run command like `db.getUsers()` and `db.createUser()`

I have created a database user to which I have given all possible permissions. My database user has the built in atlas admin role and a custom roll that has all global actions and roles enabled However, when I connect to the database with that username and use use admin I’m still not able to run a command such db.getUsers().
In response I get:
not authorized on admin to execute command { usersInfo: 1, apiVersion: “1”, lsid: { id: UUID(“3432603c-4708-4382-bfac-31215a830b6f”) }, $clusterTime: { clusterTime: Timestamp(1720545473, 1), signature: { hash: BinData(0, E5E73F545B624591E72FA4948A2FFA0D5BE5E7E3), keyId: 7340256253127426049 } }, $db: “admin” }

I need to run the following command to enable our changeStreams to contain the pre-image but I get the same error as above
db.runCommand( {
setClusterParameter:
{ changeStreamOptions: {
preAndPostImages: { expireAfterSeconds: 100 }
} }
} )

Hello @Hani_Ghasempour ,

In the MongoDB Atlas some of the commands includes db.getUsers() and db.runCommand( { setClusterParameter: { changeStreamOptions: { preAndPostImages: { expireAfterSeconds: 100 } } } } ) are unsupportive.

Check here for Unsupported-Commands.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.