Problem with Lab: Creating First Application User

I am trying to complete this lab but am not able to pass the tests.

When I hope the in-browser IDE, I access the instance and start up the shell with this command:

mongo --port 27000 -u "m103-admin" -p "m103-pass"

Then I try to create the user with this command:

db.createUser(
  { user: "m103-application-user",
    pwd: "m103-application-pass",
    roles: [ { db: "applicationData", role: "readWrite" } ],
  }
)

Anyone able to see where I am going wrong here? I know I also need to set the authentication source as admin for the user I’m creating but I’m not sure how to do so.

You might have created the user in the wrong DB
You should switch to admin DB while creating the user
For authentication source use authenticationDatabase as admin in your mongo command

I am facing same issue

Connected with following parameters.
mongo --host localhost:27000 -u m103-admin -p m103-pass --authenticationDatabase admin

Created User
db.createUser(
{ user: “m103-application-user”,
pwd: “m103-application-pass”,
roles: [ { db: “applicationData”, role: “userAdmin” } ]
})

Response from mongo

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"
                }
        ]
}

But when running validation it fails.
3 total, 0 passed, 0 skipped: [FAIL] “The user m103-application-user was created on the admin database” Did you create the ‘m103-application-user’ on the admin database? [FAIL] “The user m103-application-user has the correct permissions” Did you create the ‘m103-application-user’ with the readWrite role on the applicationData database? [FAIL] “The user m103-application-user has the correct password” Did you create the ‘m103-application-user’ with the password ‘m103-application-pass’?

My answer is same as before.You might have created the user on wrong DB
You can check by db.getUsers()

Figured out the issue. After login switch db.
use admin

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