Kerberos authentication
- Last Updated: July 22, 2021
- 4 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.1
- Documentation
Your Kerberos environment should be fully configured before you configure the driver for Kerberos authentication. You should refer to your MongoDB and Java documentation for instructions on configuring Kerberos. For a Windows Active Directory implementation, you should also consult your Windows documentation. For a non-Active Directory implementation (on a Windows or non-Windows operating system), you should consult MIT Kerberos documentation.
Once your Kerberos environment has been configured, take the following steps to configure the driver.
The following examples demonstrate the required properties for a session using Kerboros authentication. Properties not specified in the example use the default setting.
For a connection URL:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:mongodb://myserver:27017;AuthenticationMethod=kerberos;
DatabaseName=mydb;");
For a data source:
MongoDBDataSource mds = new MongoDBDataSource();
mds.setDescription("My MongoDB Data Source");
mds.setAuthenticationMethod("kerberos");
mds.setDatabaseName("mydb");
mds.setServerName("myserver");