Read-only users only have read permissions. Thus, a user who has readonly true does not have the right to add new users or any write options.
I am creating a utility that manages data in MongoDB. When I log in as a read-only user, it should not allow me to add a new user. When I implement it, it does not actually add the user, but does not raise any exceptions.
Here are my commands for adding a read-only user
var credentials = new MongoCredentials(username, password,false);
var addUser = new MongoUser(credentials, readOnly);
var database = server.GetDatabase(databaseName);
database.AddUser(addUser);
source
share