[SERVER-65063] mongoexport could not connect to server with username issue Created: 30/Mar/22  Updated: 17/May/22  Resolved: 17/May/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Huang Teng Assignee: Chris Kelly
Resolution: Done Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB shell version v4.4.13
Build Info: {
"version": "4.4.13",
"gitVersion": "df25c71b8674a78e17468f48bcda5285decb9246",
"openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013",
"modules": [],
"allocator": "tcmalloc",
"environment":

{ "distmod": "rhel70", "distarch": "x86_64", "target_arch": "x86_64" }

}


Participants:

 Description   

Problem Statement/Rationale

running follow command

```
mongoexport --host dbhost --port 27017 --db=mms-service --collection=document --type=csv --fields=_id --query='{}' --limit 10 --out exported.csv -u=user.name --authenticationDatabase admin
```

but i get an error

```
could not connect to server: connection() error occured during connection handshake: handshake failure: username must contain a '.' separated database.user pair
```

what is the meaning of the error, it is the issue of the username, a dot in the username?

i also try to add quote to the username: "user.name", 'user.name', same error

 

Steps to Reproduce

use mongo/mongoexport to connect to the db

Expected Results

login the db successfully

Actual Results

login failed

Additional Notes

1, also try mongo command, same error
```
mongo "mongodb://user.name:password@db-host:27017/?authSource=admin"

mongo --host dbhost --port 27017 -u user.name -p password --authenticationDatabase admin
```
error message:
```
MongoDB shell version v4.4.13
connecting to: mongodb://dbhost:27017/authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Error: username must contain a '.' separated database.user pair :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
```

2, connect the db without auth, then auth by db.auth(), in this way, i can login into the db
```
mongo --host dbhost -p 27017
db.auth("user.name", "password") – the quote required
user dbname
show collections
```
it show the collections.



 Comments   
Comment by Chris Kelly [ 17/May/22 ]

Hello Huang,

We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Regards,
Christopher

Comment by Chris Kelly [ 09/May/22 ]

Hello Huang,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please:

  • Upload your mongo.log file covering the time period in which you attempt to log in from the command line and receive this error
  • Point out the timestamp around when you get the error

Your secure upload portal link is accessible here.

Regards,
Christopher

Comment by Chris Kelly [ 07/Apr/22 ]

Hello huang.teng@gloritysolutions.com,

I attempted to replicate your issue on MongoDB v4.4.13 (running shell version v.4.4.13) by creating a user called “test.user” on the “admin” db.

I was able to connect successfully via the command line using all of the methods you proposed (creating a db/collection to mimic your case):

mongo "mongodb://user.name:password@db-host:27017/?authSource=admin"

mongo --host dbhost --port 27017 -u user.name -p password --authenticationDatabase admin

mongoexport --host dbhost --port 27017 --db=mms-service --collection=document --type=csv --fields=_id --query='{}' --limit 10 --out exported.csv -u=user.name --authenticationDatabase admin

Because I don’t see this issue on my end when using “.” in the username, both with and without quotes, I’m not certain that’s what the problem is. If there are steps in your reproduction that I may be missing, please let me know.

Otherwise, in order to look into this further, please help me with the following:

  • Upload your mongo.log file covering the time period in which you attempt to log in from the command line and receive this error
  • Point out the timestamp around when you get the error

I've created a secure upload portal for you. Files uploaded to this portal are visible only to MongoDB employees and are routinely deleted after some time.

Regards,
Christopher

Generated at Thu Feb 08 06:01:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.