SSIS Components for Microsoft Dynamics CRM

Build 23.0.8839

Establishing a Connection

Enabling SSIS in Visual Studio 2022

If you're using Visual Studio 2022, you will need to install the SQL Server Integration Services Projects extension to use SSIS.

  1. Navigate to Extensions > Manage Extensions.
  2. In the Manage Extensions window's search box, search for "SQL Server Integration Services Projects 2022" and select the extension in the list.
  3. Click Download.
  4. Close Visual Studio and run the downloaded Microsoft.DataTools.IntegrationServices.exe installer. Proceed through the installer with default settings.
  5. Open Visual Studio. There should now be an "Integration Services Project" project template available.

Adding the Microsoft Dynamics CRM Connection Manager

Create a new connection manager as follows:

  1. Create a Visual Studio project with the "Integration Services Project" template.
  2. In the project, right-click within the Connection Managers window and select New Connection from the menu.
  3. In the Description column, select CData Microsoft Dynamics CRM Connection Manager and click Add...
  4. Configure the component as described in the next section.

Alternatively, if you have an existing project and CData Microsoft Dynamics CRM Source or CData Microsoft Dynamics CRM Destination:

  1. Right-click your CData Microsoft Dynamics CRM source or destination component in your data flow
  2. Select Edit... to open an editor window.
  3. Click the New... button next to the Connection manager: dropdown selector to create a connection manager.
  4. Configure the component as described in the next section.

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 component 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 component opens the Azure AD endpoint in your default browser. Log in and grant permissions to the application. The component then completes the following Azure AD process:

  1. Gets the callback URL and sets the access token and ADFSServer to authenticate requests.
  2. Saves OAuth values in your connection settings. These values persist across connections.
  3. 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

  • InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
  • 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 component opens Microsoft Dynamics CRM's OAuth endpoint in your default browser. Log in and grant permissions to the application.

After you grant permissions to the application, the component then completes the OAuth process:

  1. The component obtains an access token from Microsoft Dynamics CRM and uses it to request data.
  2. The OAuth values are saved in the path specified in OAuthSettingsLocation. These values persist across connections.

When the access token expires, the component 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.

  1. 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 component on another machine and transfer the OAuth authentication values after you authenticate through the usual browser-based flow.

  2. Then configure the component 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.

  1. 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.
      Then call the GetOAuthAuthorizationUrl stored procedure with the appropriate CallbackURL. Open the URL returned by the stored procedure in a browser.

  2. Log in and grant permissions to the component. You are then redirected to the callback URL, which contains the verifier code.
  3. Save the value of the verifier code. Later you need this for the OAuthVerifier connection property.
Next, you need to exchange the OAuth verifier code for OAuth refresh and access tokens. Set the following properties:

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 component 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 component 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 SSIS Components 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 SSIS Components 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.

  1. 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.
  2. 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.

  1. Open the Subscriptions page by searching and selecting the Subscriptions service from the search bar.
  2. Select the subscription to assign the application to.
  3. Open the Access control (IAM) and select Add > Add role assignment to open the Add role assignment page.
  4. Select Owner as the role to assign to your created Azure AD app.
Complete the Authentication You are ready to connect after

  1. setting the properties described "In Both Methods" below.
  2. 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:

  1. AuthScheme: The AzureServicePrincipal in your application settings.
  2. InitiateOAuth: GETANDREFRESH. Use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  3. AzureTenant: The tenant you wish to connect to.
  4. OAuthClientId: The client Id in your application settings.
Authenticating using a Client Secret

Continue with the following:

  1. OAuthClientId: The client Id in your application settings.
  2. OAuthClientSecret: The client secret in your application settings.

Authenticating using a Certificate

Continue with the following:

  1. OAuthJWTCert: The JWT Certificate store.
  2. OAuthJWTCertType: The type of the certificate store specified by OAuthJWTCert.

Kerberos

See Using Kerberos for details on how to authenticate with Kerberos.

  1. 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.
  2. 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.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839