Linux DSN Configuration
This section describes how to set up ODBC connectivity and configure DSNs on several Linux distributions: Debian-based systems, like Ubuntu, and Red Hat Linux platforms, like Red Hat Enterprise Linux (RHEL), CentOS, and Fedora.
Minimum Linux Versions
Here are the minimum supported versions for Red Hat-based and Debian-based systems:
OS | Min. Version |
Ubuntu | 11.04 |
Debian | 7 |
RHEL | 6.9 |
CentOS | 6.9 |
Fedora | 13 |
SUSE | 12.1 |
Installing the Driver Dependencies
Run the following commands as root or with sudo to install the necessary dependencies:
- Debian/Ubuntu:
apt-get install libc6 libstdc++6 zlib1g libgcc1
- RHEL/CentOS/Fedora:
yum install glibc libstdc++ zlib libgcc
Here are the corresponding libraries required by the driver:
Debian/Ubuntu Package | RHEL/CentOS/Fedora Package | File |
libc6 | glibc | linux-vdso.1 |
libc6 | glibc | libm.so.6 |
libc6 | glibc | librt.so.1 |
libc6 | glibc | libdl.so.2 |
libc6 | glibc | libpthread.so.0 |
libc6 | glibc | libc.so.6 |
libc6 | glibc | ld-linux-x86-64.so.2 |
libstdc++6 | libstdc++ | libstdc++.so.6 |
zlib1g | zlib | libz.so.1 |
libgcc1 | libgcc | libgcc_s.so.1 |
Installing the Driver
You can use standard package management systems to install the driver.
On Debian-based systems, like Ubuntu, run the following command with root or sudo:
dpkg -i /path/to/driver/setup/DynamicsCRMODBCDriverforUnix.deb
On systems that support the RPM package format, run the following command with root or sudo:
rpm -ivh /path/to/driver/DynamicsCRMODBCDriverforUnix.rpm
Licensing the Driver
Run the following commands to license the driver. To activate a trial, omit the <key> input.
cd /opt/cdata/cdata-odbc-driver-for-dynamicscrm/bin/
sudo ./install-license.sh <key>
Connecting through the Driver Manager
The driver manager loads the driver and passes function calls from the application to the driver. You need to register the driver with the driver manager and you define DSNs in the driver manager's configuration files.
The driver installation registers the driver with the unixODBC driver manager and creates a system DSN. The unixODBC driver manager can be used from Python and from many other applications. Your application may embed another driver manager.
Creating the DSN
See Using unixODBC to install unixODBC and configure DSNs. See Using the DataDirect Driver Manager to create a DSN to connect to OBIEE, Informatica, and SAS.
Connecting to Microsoft Dynamics CRM
To connect, set Url to the root URL of your organization and set User, Password, and CRMVersion.
Authenticating to Microsoft Dynamics CRM
CRM On-Premises
For CRM on-premises, select an authentication method.
By default, the driver uses Windows (NTLM) authentication. To use another authentication type, such as Kerberos delegation, set AuthScheme.
The following is an example connection string:
AuthScheme=Auto;Url=https://myOrg.crm.dynamics.com/;User=username;Password=password;CRM Version='CRM2011+'"
Internet-Facing Deployments
For Dynamics CRM with IFD, set InternetFacingDeployment to true.
The following is an example connection string:
AuthScheme=Auto;Url=https://myOrg.crm.dynamics.com/;User=username;Password=password;InternetFacingDeployment=True;CRM Version='CRM2011+'"
Azure AD
Microsoft Dynamics CRM supports Azure AD. To authenticate using Azure AD, you must create a custom application to obtain the OAuthClientId, OAuthClientSecret to use custom Azure AD credentials.Set your AuthScheme to AzureAD. The rest of the Azure AD flows assume that you have done so.
When you connect, the driver opens the Azure AD endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the following Azure AD process:
- Gets the callback URL and sets the access token and ADFSServer to authenticate requests.
- Saves OAuth values in your connection settings. These values persist across connections.
- Exchanges the returned refresh token for a new, valid access token.
The following is an example connection string for Internet-Facing Deployments:
AuthScheme=OAuth;Url=https://myOrg.crm.dynamics.com/;CRM Version=CRM2011+;InitiateOAuth=GETANDREFRESH;CallbackUrl=http://localhost:33333;OAuthClientId=ClientID;ADFSServer=https://auth.adfs.com/;"The following is an example connection string for Online Instance:
AuthScheme=OAuth;Url=https://myOrg.crm.dynamics.com/;CRM Version=CRMOnline;InitiateOAuth=GETANDREFRESH;CallbackUrl=http://localhost:33333;OAuthClientId=ClientID;AzureTenant=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;"
Desktop Applications
To authenticate with the credentials for a custom OAuth application, you must get and refresh the OAuth access token. After you do that, you are ready to connect.Get and Refresh the OAuth Access Token
- OAuthClientId: The client Id assigned when you registered your application.
- OAuthClientSecret: The client secret that was assigned when you registered your application.
- CallbackURL: The redirect URI that was defined when you registered your application.
When you connect, the driver opens Microsoft Dynamics CRM's OAuth endpoint in your default browser. Log in and grant permissions to the application.
When the access token expires, the driver refreshes it automatically.
Headless Machines
To configure the driver, use OAuth with a user account on a headless machine. You need to authenticate on another device that has an internet browser.
- Choose one of these two options:
- Option 1: Obtain the OAuthVerifier value as described in "Obtain and Exchange a Verifier Code" below.
- Option 2: Install the driver on another machine and transfer the OAuth authentication values after you authenticate through the usual browser-based flow.
- Then configure the driver to automatically refresh the access token from the headless machine.
Option 1: Obtain and Exchange a Verifier Code
To obtain a verifier code, you must authenticate at the OAuth authorization URL.
Follow the steps below to authenticate from the machine with an internet browser and obtain the OAuthVerifier connection property.
- Choose one of these options:
- If you are using the Embedded OAuth Application click Microsoft Dynamics CRM OAuth endpoint to open the endpoint in your browser.
- If you are using a custom OAuth application, create the Authorization URL by setting the following properties:
- InitiateOAuth: OFF.
- OAuthClientId: The client Id assigned when you registered your application.
- OAuthClientSecret: The client secret assigned when you registered your application.
- Log in and grant permissions to the driver. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. Later you need this for the OAuthVerifier connection property.
On the headless machine, set the following connection properties to obtain the OAuth authentication values:
- InitiateOAuth: REFRESH.
- OAuthVerifier: The verifier code.
- OAuthClientId: (custom applications only) The client Id in your custom OAuth application settings.
- OAuthClientSecret: (custom applications only) The client secret in the custom OAuth application settings.
- OAuthSettingsLocation: The location of the file where the driver saves the OAuth token values that persist across connections.
After the OAuth settings file is generated, you need to re-set the following properties to connect:
- InitiateOAuth: REFRESH.
- OAuthClientId: (custom applications only) The client Id assigned when you registered your application.
- OAuthClientSecret: (custom applications only) The client secret assigned when you registered your application.
- OAuthSettingsLocation: The location containing the encrypted OAuth authentication values. Make sure this location grants read and write permissions to the driver to enable the automatic refreshing of the access token.
Option 2: Transfer OAuth Settings
Prior to connecting on a headless machine, you need to create and install a connection with the driver on a device that supports an internet browser. Set the connection properties as described in "Desktop Applications" above.
After completing the instructions in "Desktop Applications", the resulting authentication values are encrypted and written to the location specified by OAuthSettingsLocation. The default filename is OAuthSettings.txt.
Once you have successfully tested the connection, copy the OAuth settings file to your headless machine.
On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: REFRESH.
- OAuthClientId: (custom applications only) The client Id assigned when you registered your application.
- OAuthClientSecret: (custom applications only) The client secret assigned when you registered your application.
- OAuthSettingsLocation: The location of your OAuth settings file. Make sure this location gives read and write permissions to the driver to enable the automatic refreshing of the access token.
Admin Consent
Admin consent refers to when the Admin for an Azure Active Directory tenant grants permissions to an application which requires an admin to consent to the use case. The embedded application within the CData ODBC Driver for Microsoft Dynamics CRM, contains no permissions that require admin consent. Therefore, this information applies only to custom applications.
Admin Consent Permissions
When creating a new OAuth application in the Azure Portal, you must specify which permissions the application requires. Some permissions may be marked stating "Admin Consent Required". For example, all Groups permissions require Admin Consent. If your application requires admin consent, there are a couple of ways this can be done.
The easiest way to grant admin consent is to request that an admin log into portal.azure.com and navigate to the application you have created in App Registrations. Under API Permissions, there is a button for Grant Consent. You can consent here for your application to have permissions on the tenant it was created under.
After an admin grants consent, you can perform authentication as normal.
Client Credentials
Client credentials refers to a flow in OAuth where there is no direct user authentication taking place. Instead, credentials are created for just the application itself. All tasks taken by the application are done without a default user context. This makes the authentication flow a bit different from standard.Client OAuth Flow
All permissions related to the client oauth flow require admin consent. This means the application embedded with the CData ODBC Driver for Microsoft Dynamics CRM cannot be used in the client oauth flow. You must create your own OAuth application to use client credentials. See Creating a Custom OAuth Application for more details.
In your App Registration in portal.azure.com, navigate to API Permissions and select the Microsoft Graph permissions. There are two distinct sets of permissions - Delegated and Application permissions. The permissions used during client credential authentication are under Application Permissions. Select the applicable permissions you require for your integration.
You are ready to connect after setting one of the below connection properties groups depending on the authentication type.
- Client Secret
- InitiateOAuth: GETANDREFRESH. Use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you wish to connect to.
- OAuthGrantType: CLIENT.
- OAuthClientId: The Client Id in your application settings.
- OAuthClientSecret: The Client Secret in your application settings.
- Certificate
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you wish to connect to.
- OAuthGrantType: CLIENT.
- OAuthClientId: The Client Id in your application settings.
- OAuthJWTCert: The JWT Certificate store.
- OAuthJWTCertType: The type of the certificate store specified by OAuthJWTCert.
Authentication with client credentials takes place automatically like any other connection, except there is no window opened prompting the user. Because there is no user context, there is no need for a browser popup. Connections take place and are handled internally.
Azure Service Principal
Authentication as an Azure Service Principal is handled via the OAuth Client Credentials flow, and it does not involve direct user authentication. Instead, credentials are created for just the application itself. All tasks taken by the application are done without a default user context but based on the assigned roles. The application access to the resources is controlled through the assigned roles' permissions.Create an Azure AD App and an Azure Service Principal
When authenticating using an Azure Service Principal, you must register an application with an Azure AD tenant. Assign a role to the application To access resources in your subscription, you must assign a role to the application.- Open the Subscriptions page by searching and selecting the Subscriptions service from the search bar.
- Select the subscription to assign the application to.
- Open the Access control (IAM) and select Add > Add role assignment to open the Add role assignment page.
- Select Owner as the role to assign to your created Azure AD app.
- setting the properties described "In Both Methods" below.
- setting group properties. Choosing the group depends on the configured application authentication (client secret or certificate).
In Both Methods
Before choosing client secret or certificate authentication, follow these steps then continue to the relevant section below:
- AuthScheme: The AzureServicePrincipal in your application settings.
- InitiateOAuth: GETANDREFRESH. Use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you wish to connect to.
- OAuthClientId: The client Id in your application settings.
Continue with the following:
- OAuthClientId: The client Id in your application settings.
- OAuthClientSecret: The client secret in your application settings.
Authenticating using a Certificate
Continue with the following:
- OAuthJWTCert: The JWT Certificate store.
- OAuthJWTCertType: The type of the certificate store specified by OAuthJWTCert.
Kerberos
See Using Kerberos for details on how to authenticate with Kerberos.
- Client Secret
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you wish to connect to.
- OAuthGrantType: CLIENT.
- OAuthClientId: The client Id in your application settings.
- OAuthClientSecret: The client secret in your application settings.
- Certificate
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you wish to connect to.
- OAuthGrantType: CLIENT.
- OAuthClientId: The client Id in your application settings.
- OAuthJWTCert: The JWT Certificate store.
- OAuthJWTCertType: The type of the certificate store specified by OAuthJWTCert.
Refreshing OAuth Values
The driver can refresh the temporary OAuth access tokens obtained during the browser-based OAuth authentication exchange. By default, the driver saves the encrypted tokens in the odbc.ini file corresponding to the DSN. Access to this odbc.ini file can be restricted in the case of System DSNs.
To enable the automatic token exchange, you can give the driver write access to the system odbc.ini. Or, you can set the OAuthSettingsLocation connection property to an alternate file path, to which the driver would have read and write access.
OAuthSettingsLocation=/tmp/oauthsettings.txt
Installing Dependencies for OAuth Authentication
The OAuth authentication standard requires the authenticating user to interact with Microsoft Dynamics CRM, using a web-browser. If the first OAuth interaction is to be done on the same machine the driver is installed on, for example, a desktop application, the driver needs access to the xdg-open program, which opens the default browser.
To satisfy this dependency, install the corresponding package with your package manager:
Debian/Ubuntu Package | RHEL/CentOS/Fedora Package | File |
xdg-utils | xdg-utils | xdg-open |
Set the Driver Encoding
The ODBC drivers need to specify which encoding to use with the ODBC Driver Manager. By default, the CData ODBC Drivers for Unix are configured to use UTF-16 which is compatible with unixODBC, but other Driver Managers may require alternative encoding.
Alternatively, if you are using the ODBC driver from an application that uses the ANSI ODBC API it may be necessary to set the ANSI code page. For example, to import Japanese characters in an ANSI application, you can specify the code page in the config file '/opt/cdata/cdata-odbc-driver-for-dynamicscrm/lib/cdata.odbc.dynamicscrm.ini':
[Driver]
AnsiCodePage = 932