Can't authenticate to MongoDB with C++ code

350 views Asked by At

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 }

  • Without authentication, I can read and write to the DB form the code
  • Couldn't find any documentation about the response
1

There are 1 answers

0
Ran P On BEST ANSWER

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