@@ -122,6 +122,48 @@ option for programmatic usage of ``mongosh``, like a :driver:`driver
122
122
- To provision access to a MongoDB deployment, see :manual:`Database
123
123
Users </core/security-users/>`.
124
124
125
+
126
+ Connect with LDAP
127
+ ~~~~~~~~~~~~~~~~~
128
+
129
+ To connect to a deployment using :ref:`LDAP <security-ldap>`:
130
+
131
+ - Set :option:`--username <mongosh --username>` to a username that
132
+ respects the :setting:`security.ldap.authz.queryTemplate`, or any
133
+ configured :setting:`security.ldap.userToDNMapping` template.
134
+
135
+ - Set :option:`--password <mongosh --password>` to the appropriate
136
+ password. If you do not specify the password to the
137
+ ``--password`` command-line option, ``mongosh`` prompts you for
138
+ the password.
139
+
140
+ - Set :option:`--authenticationDatabase <mongosh --authenticationDatabase>`
141
+ to ``$external``.
142
+ The ``$external`` argument must be placed in single quotes, not
143
+ double quotes, to prevent the shell from interpreting ``$external``
144
+ as a variable.
145
+
146
+ - Set :option:`--authenticationMechanism <mongosh --authenticationMechanism>`
147
+ to ``PLAIN``.
148
+
149
+ .. warning::
150
+
151
+ When you use one-time passwords with LDAP authentication, adding
152
+ the :ref:`connection string options <connections-connection-options>`
153
+ ``maxPoolSize=1&srvMaxHosts=1`` to your connection string is
154
+ recommended to reduce the potential for connection failures.
155
+
156
+ Include the :option:`--host <mongosh --host>` and
157
+ :option:`--port <mongosh --port>` of the MongoDB deployment, along with
158
+ any other options relevant to your deployment.
159
+
160
+ For example, the following operation authenticates to a MongoDB
161
+ deployment running with LDAP authentication and authorization:
162
+
163
+ .. code-block:: bash
164
+
165
+ mongosh --username alice@dba.example.com --password --authenticationDatabase '$external' --authenticationMechanism "PLAIN" --host "mongodb.example.com" --port 27017
166
+
125
167
Connect to a Replica Set
126
168
~~~~~~~~~~~~~~~~~~~~~~~~
127
169
0 commit comments