nightroman / Mdbc

MongoDB Cmdlets for PowerShell
Apache License 2.0
141 stars 16 forks source link

Connect-Mdbc via LDAP #40

Closed emanuele1986 closed 4 years ago

emanuele1986 commented 4 years ago

Hi Roman,

i'm using mongo mdbc cmdlet with powershell to connect to my mongodb atlas without LDAP and it work fine(i use scram auth).

Also, i'm trying to connect to another mongodb atlas configured in LDAP but i got this error:

image

connection don't return any error but when i go to getdb i receve that error.

If can help here connection string used with mongoshell(works fine):

mongo "mongodb://user:pass@hostname/?authMechanism=PLAIN&authSource=%24external&retryWrites=true&readPreference=primaryPreferred" --tls --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates

we add --tls --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates in more respect powershell

is a bug or is not possible to connect to a mongodb in ldap?

Thanks for the help

nightroman commented 4 years ago

Hi @emanuele1986

connection don't return any error but when i go to getdb i receve that error.

This part is "fine", that is how C# driver works, for good or bad. The actual connection happens only when an actual request is invoked, not on the client creation.

The second part. Are you sure you use the connection strings similar to the sample with mongo? Please double check, use the required options, see https://docs.mongodb.com/manual/reference/connection-string/

For example I do not see options related to tls that you use in mongo command.

nightroman commented 4 years ago

In other words, in order to match your worked mongo command, the connection string should contain these options:

...&tls=true&tlsAllowInvalidHostnames=true&tlsAllowInvalidCertificates=true

Please try and let me know if it helps.

NB It's worth to try tlsInsecure=true as well.

emanuele1986 commented 4 years ago

Hi Roman,

yesterday night i solved for connection via mdbc. I found that options on mongo website:

&tls=true&tlsAllowInvalidHostnames=true&tlsAllowInvalidCertificates=true&tlsInsecure=true

tlsInsecure=true is mandatory in my case, without i can't connect

Thanks a lot for the help :)

nightroman commented 4 years ago

Great, I am glad you solved the problem. Closing.