无法使用 C++ 代码向 MongoDB 进行身份验证

Can't authenticate to MongoDB with C++ code

我正在尝试通过身份验证连接到本地 MongoDB,但失败了。

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

auth() returns 始终为 false,errMsg 为 { ok: 0.0, errmsg: "auth failed", code: 18 }

Neil Lunnacm 是对的。使用较新版本确实解决了身份验证问题。 谢谢