Microsoft Entra ID authentication
- Last Updated: June 28, 2024
- 4 minute read
- DataDirect Connectors
- JDBC
- Microsoft SQL Server 6.0
- Documentation
- User and password authentication: The driver authenticates using the Entra ID user and password.
- Service principal user authentication: The driver retrieves an access token by authenticating using the principal id of the logical server and the client secret of your Entra ID application.
- Managed identity authentication: The driver authenticates using a system-assigned or user-assigned managed identity. Managed identities are a type of service principal that can be used only with Azure resources for which they are granted permissions. Using managed identities to authenticate provides an alternative to using credentials, and they can be used anywhere Entra ID authentication is supported.
javax.net.ssl.trustStore Java system
property. The truststore location cannot be specified using the driver's Truststore
property.User and password authentication
To use user and password authentication with Entra ID:
-
Set the AuthenticationMethod property to specify a value of
ActiveDirectoryPassword. - Set the User property to specify your Entra ID username using the
userid@domain.comformat. - Set the Password property to specify your Entra ID password.
- Specify values for minimum required properties for establishing a connection.
- Set the ServerName property to specify either the IP address in IPv4 or IPv6
format, or the server name for your Azure server. For example,
myserver.database.windows.net. - Set the PortNumber property to specify the TCP port of the primary database server that is listening for connections to the database.
- Set the ServerName property to specify either the IP address in IPv4 or IPv6
format, or the server name for your Azure server. For example,
For example, the following is a connection string with only the required options for making a connection using Entra ID authentication.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:sqlserver://your_server.database.windows:1433;
AuthenticationMethod=ActiveDirectoryPassword;
User=test@mydomain.com;Password=secret");
Service principal user authentication
To use service principal user authentication with Entra ID:
- Set the AuthenticationMethod property to specify a value of
ActiveDirectoryServicePrincipal. - Set the ActiveDirectoryPrincipalID property to specify the Entra ID Identity (PrincipalID) of the Azure SQL logical server.
- Set the ActiveDirectoryPrincipalSecret property to specify the client secret for your Entra ID application.
- Specify values for minimum required properties for establishing a connection.
- Set the ServerName property to specify either the IP address in IPv4
or IPv6 format, or the server name for your Entra ID server. For example,
myserver.database.windows.net. - Set the PortNumber property to specify the TCP port of the primary database server that is listening for connections to the database.
- Set the ServerName property to specify either the IP address in IPv4
or IPv6 format, or the server name for your Entra ID server. For example,
For example, the following is a connection string with only the required options for making a connection using Entra ID authentication.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:sqlserver://your_server.database.windows:1433;
AuthenticationMethod=ActiveDirectoryServicePrincipal;
ActiveDirectoryPrincipalID=789f8b4c-7a4a-445d-6oe9-7bec14625645;
ActiveDirectoryPrincipalSecret=ABcdEFg/hiJkLmNOPqR01stUvWxyzYx2wvUTsrQpO=");
Managed identity authentication
- User-assigned authentication: The driver
authenticates using the client ID of the user assigned managed identity.
To use user-assigned managed identity authentication with Entra ID:
- Set the AuthenticationMethod property to the value
ActiveDirectoryManagedIdentity. - Set the User property to specify your Microsoft Entra ID (Azure)
client ID of the user assigned managed identity. Note: The
Userproperty is optional if only one user-assigned managed identity is configured. This property is required if there are more than one user-assigned managed identities configured. - Specify values for minimum required properties for establishing
a connection.
- Set the ServerName property to specify either the IP address
in IPv4 or IPv6 format, or the server name for your Entra ID (Azure) server. For
example,
myserver.database.windows.net. - Set the PortNumber property to specify the TCP port of the primary database server that is listening for connections to the database.
- Set the ServerName property to specify either the IP address
in IPv4 or IPv6 format, or the server name for your Entra ID (Azure) server. For
example,
- Optionally, set the DatabaseName property to the database to which you want to connect.
For example, the following is a connection string with the minimal options for making a connection using managed identity authentication.
Connection conn = DriverManager.getConnection ("jdbc:datadirect:sqlserver://your_server.database.windows:1433;DatabaseName=exampleDB; AuthenticationMethod=ActiveDirectoryManagedIdentity;User=f4f42d67-6789-4d58-a789-83a3dc123456"); - Set the AuthenticationMethod property to the value
- System-assigned authentication: The driver
authenticates using the identity associated with Azure resources like virtual
machines.
To use system-assigned managed identity authentication with Entra ID:
- Set the AuthenticationMethod property to specify a value of
ActiveDirectoryManagedIdentity. - Specify values for minimum required properties for establishing
a connection.
- Set the ServerName property to specify either the IP address
in IPv4 or IPv6 format, or the server name for your Azure server. For example,
myserver.database.windows.net. - Set the PortNumber property to specify the TCP port of the primary database server that is listening for connections to the database.
- Set the ServerName property to specify either the IP address
in IPv4 or IPv6 format, or the server name for your Azure server. For example,
- Optionally, set the DatabaseName property to the database to which you want to connect.
For example, the following is a connection string with the minimal options for making a connection using managed identity authentication.
Connection conn = DriverManager.getConnection ("jdbc:datadirect:sqlserver://your_server.database.windows:1433;DatabaseName=exampleDB; AuthenticationMethod=ActiveDirectoryManagedIdentity"); - Set the AuthenticationMethod property to specify a value of