Creating the Data Source Name
This section describes how to edit the DSN configuration and then authenticate and connect to Microsoft Dynamics 365 APIs.
DSN Configuration
You can use the Microsoft ODBC Data Source Administrator to edit the DSN configuration. Note that the installation process creates a both a user DSN and a system DSN, as described in Installing the Connector.
Note: The connector stores connection information in the Windows registry. To ensure that the connector can write to the registry, either run Power BI as an administrator or use a User DSN for your connection instead of a System DSN.
User DSN
Complete the following steps to edit the DSN configuration:
- Select Start > Search, and enter ODBC Data Sources in the Search box.
- Choose the version of the ODBC Administrator that corresponds to the bitness of your Power BI Desktop installation (32-bit or 64-bit).
- Select the system data source and click Configure.
- Edit the information on the Connection tab and click OK.
System DSN
Configure the system DSN the same way as the user DSN, except you will need to switch to the System DSN tab before performing Step 3.
If you're using Power BI's On-Premises Data Gateway with Standard mode, you must use the system DSN.
You must also specify a valid location for OAuthSettingsLocation (a path where OAuth credentials are locally stored to avoid repeated OAuth prompts).
This is because the Standard mode runs on service mode and can only access permitted locations, such as C:\Windows\ServiceProfiles\PBIEgwService\AppData\Local\Microsoft\On-premises data gateway.
Connecting to Microsoft Dynamics 365
The Microsoft Dynamics 365 driver supports connecting to the following Microsoft Dynamics 365 editions:
- CustomerService
- FieldService
- FinOpsOnline (Default)
- FinOpsOnPremise
- HumanResources
- Marketing
- ProjectOperations
- Sales
Notes:
- Supply Chain Management is the same as Finance and Operations. To connect to either of these, set Edition to either FinOpsOnline or FinOpsOnPremise.
- For Microsoft Dynamics 365 Business Central, use the separate Microsoft Dynamics 365 Business Central driver.
To connect, set these parameters:
- RSBDynamics365_p_OrganizationURL: The URL to your Microsoft Dynamics 365 organization; for example, https://orgcb42e1d0.crm.dynamics.com.
- Edition: As shown in the list of editions above.
Authenticating to Microsoft Dynamics 365
Microsoft Dynamics 365 supports authentication via Azure AD, Azure Service Principal, or Azure Managed Service Identity (MSI). All of these are based on the OAuth standard.
Azure AD
Authenticating via Azure AD requires you to create a custom AzureAD application, as described in Creating an Azure AD Application. You can authenticate with either a client secret or a JWT certificate.To connect, set these properties:
- AuthScheme: AzureAD.
- InitiateOAuth: GETANDREFRESH. This setting enables you to use InitiateOAuth to avoid repeating the AzureAD exchange and manually setting the OAuthAccessToken.
- AzureTenant: The Azure tenant to which you will connect.
- OAuthClientId: The Client Id assigned when you created your custom application.
- OAuthClientSecret (Client Secret only): The Client Secret assigned when you created your custom application.
- OAuthJWTCert (Certificate only): The JWT Certificate store.
- OAuthJWTCertType (Certificate only): The type of the certificate store specified by OAuthJWTCert.
Admin Consent
Admin consent refers to permissions granted by an Azure AD Tenant's admin to a custom application, as required for the use case. (Since the embedded application within the CData Power BI Connector for Microsoft Dynamics 365 contains no permissions that require Admin consent, admin consent only applies to custom applications.)If your organization requires admin consent for authorizing any new OAuth application for your Azure Tenant, it means that the first time someone in your organization installs and uses an OAuth application, an administrator for the organization must explicitly grant that application access.
(Your organization can choose to disable this requirement.)
Granting Admin Consent
When creating a new OAuth application in the Azure Portal (see Creating an Azure AD Application), you must specify which permissions the application requires. If you know that your organization requires admin consent for new custom applications, you can start by specifying permissions that are already labeled Admin Consent Required. (For example, all Groups permissions require admin consent.)
There are two ways to grant admin consent:
- The easiest way to grant admin consent is to just have an admin log into portal.azure.com and navigate to the application you have created in App Registrations. Under API Permissions, click Grant Consent. This grants your application the necessary permissions on the tenant on which it was created.
- If your organization has multiple tenants or the application needs to be granted permissions for other tenants outside your organization, you can use the GetAdminConsentURL to generate the Admin Authorization URL. Unlike the GetOAuthAuthorizationUrl, there is no important information returned from this endpoint. If the tenant grants access, it returns a Boolean confirming that permissions were granted.
After an admin grants consent, authentication is performed as usual.
Client Credentials Auth Flow
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.All permissions related to the client OAuth flow require admin consent. This means the application embedded with the CData Power BI Connector for Microsoft Dynamics 365 cannot be used in the client OAuth flow. You must create your own OAuth application to use client credentials, as described in Creating an Azure AD Application.
To do this:
- Login to portal.azure.com.
- Navigate to App Registration > API Permissions.
- Select the Microsoft Graph permissions. There are two distinct sets of permissions: Delegated Permissions and Application permissions. The permissions used during client credential authentication are under Application Permissions. Select the applicable permissions you require for your integration.
To connect, set these properties:
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant to which you will connect.
- OAuthClientId: The Client Id assigned when you created your custom application.
- OAuthClientSecret (Client Secret only): The Client Secret assigned when you created your custom application.
- OAuthJWTCert (Certificate only): The JWT Certificate store.
- OAuthJWTCertType (Certificate only): The type of the certificate store specified by OAuthJWTCert.
Azure Service Principal
Actions in Azure AD can be run by either user accounts or service principals. A service principal is a non-interactive account with elevated permissions, that performs tasks based on the roles and permissions assigned. Authentication as an Azure Service Principal is handled via the OAuth Client Credentials flow, without user involvementy Authentication as an Azure Service Principal requires you to create a custom AzureAD Service Principal application, as described in Creating a Custom AzureAD Service Principal App.When you are ready to connect, set these properties:
- AuthScheme: AzureServicePrincipal for using a Client Secret or AzureServicePrincipalCert for using a JWT certificate.
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- AzureTenant: The tenant you want to connect to.
- OAuthClientId (Client Secret only): The Client Id in your application settings.
- OAuthClientSecret (Client Secret only): The Client Secret assigned when you created your custom application.
- OAuthJWTCert (Certificate only): The JWT Certificate store.
- OAuthJWTCertType (Certificate only): The type of the certificate store specified by OAuthJWTCert.
Managed Service Identity (MSI)
If you are running Microsoft Dynamics 365 on an Azure VM and want to automatically obtain Managed Service Identity (MSI) credentials to connect, set AuthScheme to AzureMSI.
User-Managed Identities
To obtain a token for a managed identity, use the OAuthClientId property to specify the managed identity's client_id.If your VM has multiple user-assigned managed identities, you must also specify OAuthClientId.