Ran P
Ran P

Reputation: 332

Can't authenticate to MongoDB with C++ code

I'm trying to connect to a local MongoDB with authentication but failing.

DBClientConnection c;
string errMsg;
c.connect("localhost");
bool success = c.auth("ss1", "admin", "password", errMsg);

auth() returns always false, and the errMsg is { ok: 0.0, errmsg: "auth failed", code: 18 }

Upvotes: 1

Views: 388

Answers (1)

Ran P
Ran P

Reputation: 332

Neil Lunn and acm were right. Using the newer version did solve the authentication issue. Thank you

Upvotes: 1

Related Questions