This thing will make me go crazy now. I'm trying to get it to work for 3 hours without any result. I installed mongodb 2.8rc4. I created a user account in admin db. I can connect to mongod using mongo localhost/agp -u dato0011 -p "MyPassword". I can authenticate it via db.auth, but for an unknown reason, this thing doesn't work from C# driver.
Connection string is mongodb://dato0011:MyPWD@localhost/agp
I initialize the db with the following code:
        var client = new MongoClient(ConfigurationManager.ConnectionStrings["Default"].ConnectionString);
        var server = client.GetServer();
        var db = server.GetDatabase("agp");
but when I try save, I get an exception saying:
Unable to connect to server 192.168.0.100:27017: Invalid credential for database 'agp'..
and deep below inner exceptions, there's this message:
{ "authenticate" : 1, "user" : "dato0011", "nonce" : "fc65b3c269560533", "key" : "35589d31830b76c72358343bc054105f" }
and this
{"Command 'authenticate' failed: auth failed (response: { \"ok\" : 0.0, \"errmsg\" : \"auth failed\", \"code\" : 18 })"}
Anyone has any idea what am I doing wrong? Thanks.
UPDATE
Don't know if it will help, but here's the code that throws exception:
Users.Save(user);
where Users is
Users = db.GetCollection<User>("users", WriteConcern.W1);
UPDATE 2 Apparently the exception message is a bit misleading. The driver does connect to mongod, but it can't authenticate for an unknown reason. username and password parameters are passed correctly. Here's the user in admin db.
> db.system.users.find().toArray()
[
        {
                "_id" : "agp.dato0011",
                "user" : "dato0011",
                "db" : "agp",
                "credentials" : {
                        "SCRAM-SHA-1" : {
                                "iterationCount" : 10000,
                                "salt" : "GjlDJOiKf2Xn1VO/1MhWXA==",
                                "storedKey" : "vAi30QZLFkCZf6ISm5TIfIWPwZY=",
                                "serverKey" : "DBmbbRLrLXEIxFCuZ52VaSnRWwo="
                        }
                },
                "roles" : [
                        {
                                "role" : "readWrite",
                                "db" : "agp"
                        },
                        {
                                "role" : "dbAdmin",
                                "db" : "agp"
                        }
                ]
 
     
    