The driver supports user ID and password authentication.

To configure the driver to use user ID and password authentication:

  • Set the Host Name (HostName) option to specify the name or the IP address of the MongoDB server to which you want to connect. For example, myserver.
  • Set the User (User) option to specify your user ID.
  • Set the Password (Password) option to specify the password for the user connecting to the instance.
  • Optionally, set the Database Name (DatabaseName) option to specify the name of the database to which you are connecting.
  • Optionally, set the Authentication Database (AuthenticationDatabase) option to specify the database in which your user ID was created. This value allows you to explicitly select a set of credentials and permissions when the same user ID was created in multiple databases on the server.
    Note: We recommend specifying a value for the Authentication Database to ensure the correct permissions are used for your connection. If you do not specify a value for this option, the driver attempts to use your user ID with the database specified by the Database Name (DatabaseName) option. If your user ID was not created in the specified database, the driver will attempt to connect to the Admin database using your user ID and password.
  • Optionally, specify values for any additional options you want to configure.
Note: The User and Password options are not required to be stored in the connection string. They can also be sent separately by the application using the SQLConnect ODBC API. For SQLDriverConnect and SQLBrowseConnect, they will need to be specified in the connection string.

The following examples show the connection information required to establish a session using user ID and password authentication.

Connection string

DRIVER=DataDirect 8.1 MongoDB;AuthenticationDatabase=mydb2;DatabaseName=mydb;
      HostName=myserver;User=jsmith;Password=secret;

odbc.ini

[MongoDB]
Driver=ODBCHOME/lib/ivmongodb81.so
...
Description=DataDirect 8.1 MongoDB
...
AuthenticationDatabase=mydb2
...
DatabaseName=mydb
...
HostName=myserver
...
User=jsmith
...
Password=secret
...