c++mongodbauthenticationdbclient

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 }


Solution

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