[CXX-842] C++ 11 master driver - can't execute authentification Created: 12/Feb/16  Updated: 16/Feb/16  Resolved: 16/Feb/16

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Pavel Odintsov Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hello, folks!

I'm trying to connect to remote database with login/password and enabled MONGODB-CR auth mode.

So I could not achieve it:

std::string connection_string = "mongodb://user:cooPh5ohcei0Iewe@xxxx:27017/";
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{connection_string}};
 
std::cout << "username: " << conn.uri().username() << std::endl;
std::cout << "password: " <<  conn.uri().password() << std::endl;
 
auto db = conn["fastnetmon"];
std::string collection_name = "configuration";
 
if (!db.has_collection(collection_name)) {
    std::cout << "Connection failed" << std::endl;
}
{/code}
 
From Mongo's side I haven't saw any auth tries:

2016-02-12T16:10:32.132+0100 I NETWORK [initandlisten] connection accepted from xxxx:46591 #12 (1 connection now open)
2016-02-12T16:10:32.175+0100 I NETWORK [conn12] end connection xxx:46591 (0 connections now open)

{/code}

But I definitely have this database and could connect to it with standard mongo client:

 


mongo xxxxx/fastnetmon --username user --password cooPh5ohcei0Iewe --authenticationMechanism MONGODB-CR --authenticationDatabase admin{/code}

Could you help me? That's really important because I could not ask folks on other side to disable authentication.



 Comments   
Comment by Pavel Odintsov [ 12/Feb/16 ]

I've solved my issue with following connection string param:

std::string connection_string = "mongodb://user:cooPh5ohcei0Iewe@xxxx:27017/?authMechanism=MONGODB-CR&authSource=admin";

Working perfect right now!

Generated at Wed Feb 07 22:00:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.