C# application connecting to Dynamics CRM (on-premises)
This is a simple example of how a C# console app can connect to Dynamics CRM 2016 on-premises (i.e. the CDS) over the internet. Dynamics CRM being exposed using IFD with the user credential being authenticated via ADFS (which performs a similar function to Azure AD).
The CrmServiceClient class is the recommended class to connect to Dynamics CRM. One benefit of using CrmServiceClient is that it supports several authentication types. The first green box (in the code below) illustrates the CrmServiceClient being used with a network credential first and then a connection string.
The CrmServiceClient wraps both OrganizationServiceProxy and OrganizationWebProxyClient. The second green box illustrates the casting of the OrganizationWebProxyClient object to the IOrganizationService Interface.
Directly connecting to Dynamics CRM using OrganizationServiceProxy is now depreciated. The third box below illustrates this type of call.