I have a class library project already developed that create Products from F&O to Field Service through Integeration.
Microsoft has deprciated the WS-Turst (Office 365 Authentication) and Recommended to use OAuth.
Integration has been break after Code update
Connection is fine at console app or when i consume hosted integration project but when it run through the D365 Finance and Operation it give below error.
""Unable to connect to CRM: Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.LogCallback' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.23.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.\r\nCould not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.LogCallback' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.23.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Unable to Login to Dynamics CRM\r\nUnable to Login to Dynamics CRMOrganizationWebProxyClient is null\r\nOrganizationWebProxyClient is nullOrganizationWebProxyClient is null\r\nOrganizationWebProxyClient is null""
CRM Connection Code is here
private static string ConnectToMSCRM()
{
string connectionStatus = "";
try
{
//New Authentication OAuth
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
//New Authentication ClientSecret
var connectionString = "AuthType=ClientSecret;url=https://******.crm4.dynamics.com;ClientId=8b50f998-5a44-4307-8317-b6fb52bcf26c;ClientSecret=yty8Q~WdF3Xf8Nn0uTr4uCyJ0sUYD1K-KHd3Xapo";
CrmServiceClient crmConn = new CrmServiceClient(connectionString);
service = crmConn.OrganizationWebProxyClient ;
// Old obsolete code
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
//ClientCredentials credentials = new ClientCredentials();
//credentials.UserName.UserName = UserName;
//credentials.UserName.Password = Password;
//Uri serviceUri = new Uri(SoapOrgServiceUri);
//OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);
//proxy.EnableProxyTypes();
//service = (IOrganizationService)proxy;
}
catch (Exception ex)
{
connectionStatus = "Error!" "Error occurred while connecting to CRM " ex.ToString();
}
return connectionStatus;
}