User 'm103-application-user' not configured correctly - your application's user should only have the readWrite role

MongoDB Enterprise > db.createUser({user:“m103-application-user”,pwd:“m103-application-pass”,roles:[{db:“applicationData”,role:“readWrite”}]})

Successfully added user: {
“user” : “m103-application-user”,
“roles” : [
{
“db” : “applicationData”,
“role” : “readWrite”
}
]
}
MongoDB Enterprise > db.grantRolesToUser(“m103-application-user”,[{db:“applicationData”,role:“readWrite”}])

MongoDB Enterprise > db.runCommand({rolesInfo:{role:“readWrite”, db:“applicationData”},showPrivileges:true})
{
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”,
“isBuiltin” : true,
“roles” : ,
“inheritedRoles” : ,
“privileges” : [
{
“resource” : {
“db” : “applicationData”,
“collection” : “”
},
“actions” : [
“changeStream”,
“collStats”,
“convertToCapped”,
“createCollection”,
“createIndex”,
“dbHash”,
“dbStats”,
“dropCollection”,
“dropIndex”,
“emptycapped”,
“find”,
“insert”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”,
“remove”,
“renameCollectionSameDB”,
“update”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.indexes”
},
“actions” : [
“changeStream”,
“collStats”,
“dbHash”,
“dbStats”,
“find”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.js”
},
“actions” : [
“changeStream”,
“collStats”,
“convertToCapped”,
“createCollection”,
“createIndex”,
“dbHash”,
“dbStats”,
“dropCollection”,
“dropIndex”,
“emptycapped”,
“find”,
“insert”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”,
“remove”,
“renameCollectionSameDB”,
“update”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.namespaces”
},
“actions” : [
“changeStream”,
“collStats”,
“dbHash”,
“dbStats”,
“find”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”
]
}
],
“inheritedPrivileges” : [
{
“resource” : {
“db” : “applicationData”,
“collection” : “”
},
“actions” : [
“changeStream”,
“collStats”,
“convertToCapped”,
“createCollection”,
“createIndex”,
“dbHash”,
“dbStats”,
“dropCollection”,
“dropIndex”,
“emptycapped”,
“find”,
“insert”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”,
“remove”,
“renameCollectionSameDB”,
“update”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.indexes”
},
“actions” : [
“changeStream”,
“collStats”,
“dbHash”,
“dbStats”,
“find”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.js”
},
“actions” : [
“changeStream”,
“collStats”,
“convertToCapped”,
“createCollection”,
“createIndex”,
“dbHash”,
“dbStats”,
“dropCollection”,
“dropIndex”,
“emptycapped”,
“find”,
“insert”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”,
“remove”,
“renameCollectionSameDB”,
“update”
]
},
{
“resource” : {
“db” : “applicationData”,
“collection” : “system.namespaces”
},
“actions” : [
“changeStream”,
“collStats”,
“dbHash”,
“dbStats”,
“find”,
“killCursors”,
“listCollections”,
“listIndexes”,
“planCacheRead”
]
}
]
}
],
“ok” : 1
}

Hi @Amita_62847,

First of all, it’s against forum guidelines to post possible answers to labs. Suggest you edit your post and redact any lines of code that’s related to the answer.

These two commands are not necessary. Suggest you:

  1. Delete this user
  2. Make sure you switch to the admin db before you run createUser()
  3. Run createUser() and nothing else

Hi @Amita_62847,

I hope you found the post #2 made by @007_jb helpful.

If you still have any issue then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

The query has been resolved. You can close this thread.