ADO.NET Provider for Microsoft Dynamics 365 Sales

Build 22.0.8257

Using Azure Service Principal Authentication

The 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 app itself. All tasks taken by the app 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.

Azure Service Principal Authentication

When authenticating using an Azure Service Principal, you must register an application with an Azure AD tenant. Follow the steps below to create a new Azure Active Directory (Azure AD) application and service principal that can be used with the role-based access control.

Register an application with Azure AD and Create a Service Principal

Follow these steps:

  1. Log in to https://portal.azure.com.
  2. In the left-hand navigation pane, select Azure Active Directory and then App Registrations.
  3. Click New registration.
  4. Enter an app name and select Any Azure AD Directory - Multi Tenant from the radio buttons. Then set the redirect url to something such as http://localhost:33333, the driver's default.
  5. Copy the Application (client) Id value displayed on the Overview section after creating the app. This value is used as the OAuthClientId.
  6. Define the app authentication type by going to the Certificates & Secrets section. There are two types of authentication available: using a client secret and using a certificate.

    The recommended authentication method is via a certificate, but you can also create an application secret.

    • Option 1: Upload a certificate. In the Certificates & Secrets section, select Upload certificate, and then select the certificate to upload from your local machine.
    • Option 2: Create a new application secret. In the >Certificates & Secrets section, select New Client Secret for the app and specify its duration. After saving the client secret, the key value is displayed. Copy this value as it is displayed only once, and it is used as the OAuthClientSecret.

  7. On the Authentication tab, make sure to select the option Access tokens (used for implicit flows).

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 particular 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.

Authenticate with Azure Service Principal

You are ready to connect after setting one of the below connection properties groups depending on the configured app authentication (client secret or certificate).

In both methods

Before choosing client secret or certicate authentication, follow these steps then continue to the relevant section below:

  1. AuthScheme: Set this to the AzureServicePrincipal in your app settings.
  2. InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  3. AzureTenant: Set this to the tenant you wish to connect to.
  4. OAuthClientId: Set this to the Client Id in your app settings.
Authenticating using a Client Secret

Continue with the following:

  1. OAuthClientId: Set this to the Client Id in your app settings.
  2. OAuthClientSecret: Set this to the Client Secret in your app settings.

Authenticating using a Certificate

Continue with the following:

  1. OAuthJWTCert: Set this to the JWT Certificate store.
  2. OAuthJWTCertType: Set this to the type of the certificate store specified by OAuthJWTCert.

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 22.0.8257