I've the following scenario

  • Sitecore 8.2 update 2
  • MongoDB 3.2

Now, I'm trying to setup authentication to MongoDB, and as soon as I update the mongod.cfg

security: authorization: enabled

and the ConnectionStrings.config


An error shows up on Sitecore logs

Exception: MongoDB.Driver.MongoConnectionException Message: Unable to connect to server MongoServer:27017: Error: 18 - Authentication failed..

However, I've granted myuser proper permissions on the MongoDB Collection

use Sitecore_Analytics db.createUser( { user: "myuser", pwd: "mypassword", roles: [ { role: "readWrite", db: "Sitecore_Analytics" } ] } )

Also, using RoboMongo to connect to the MongoDB works!

  • Have you tried restarting the app pool? Also, can you please provide the full connection string? And does the MongoServer correct? Mar 24 '17 at 21:27
  • I've Recycled the AppPool, restarted IIS but no luck. I'll get the ConnectionStrings and add on the question Mar 24 '17 at 22:33
  • Did you create an admin user before creating the new user? Mar 24 '17 at 22:46
  • Yes, I did and I'll try modify based on your answer here Mar 24 '17 at 23:05

Looks like I've a typo in my ConnectionString, and the database Tracking_Contact didn't exist at all in the MongoDB.

However, before figure this out, I did uninstall and install all MongoDB again, and when I first accessed the Sitecore the databases were created and Tracking_Contact was named Cracking_Contact by mistake.

After fix it, and re-apply the permissions accordingly and follow the tips from Hishaam Namoya, everything start to working!

Not the answer you're looking for? Browse other questions tagged or ask your own question.