I think the problem here is you're accessing the system without the
listDatabases privilege.  There isn't a role that only confers that
permission so I suggest you create a new role that has only that
privilege.  From there, you can add that role to the appropriate users.
For example:

use admin
db.createRole(
   {
     role: "schemaAccessor",
     privileges: [
       { resource: { cluster: true }, actions: [ "listDatabases" ] }
     ],
     roles: []
   }
)

use mydbname
db.grantRolesToUser(  "myuid",  [ { role: "listDatabases", db: "admin" } ])

You may also need to confer the listCollections privilege for each database
that you want to list collections for.

Let me know if this helps resolve your issue.

Thanks,
Jacques

Reply via email to