Kerberos authentication
- Last Updated: May 24, 2021
- 1 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.1
- Documentation
This string includes the properties used to connect with Kerberos authentication.
jdbc:datadirect:mongodb://host:port;AuthenticationMethod=kerberos;DatabaseName=database;
ServicePrincipalName=principal_name;User=username;[property=value[;...]];
where:
- host
-
specifies the name or the IP address of the MongoDB server to which you want to connect. For example, myserver.
- port
-
specifies the port number of the server listener. The default is
27017.
- database
-
(optional) specifies the name of the database to which you want to connect. This value is used as the default qualifier for unqualified table names in SQL queries.Important: This value is case-insensitive if you have access privileges to query the list of databases on the server. If you do not have access, this value is case-sensitive.
- principal_name
- (optional) if the default value built by the driver does not match
the service principal name registered with the KDC, specify the three-part service
principal name. By default, the driver builds the ServicePrincipalName by concatenating
the service name
mongodb, the fully qualified domain name (FQDN) as specified with the HostName property, and the default realm name as specified in the Kerberos configuration file.
- user
- (optional) specifies the user name that is used to connect to the
MongoDB database. For example, jsmith.Note: The User property is not required to be stored in the connection string. This value can also be passed separately by the application.
- property=value
- specifies connection property settings. Multiple properties are separated by a semi-colon.
The following example connection string includes the properties required for connecting with Kerberos authentication.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:mongodb://myserver:27017;AuthenticationMethod=kerberos;
DatabaseName=mydb;user=jsmith;");