While connecting through Dynamics 365 Customer Engagement through a web application we were getting OrganizationServiceProxy value as null.
There was nothing out of ordinary in the authentication call
1 2 |
var connectionString = ConfigurationManager.AppSettings["CRMConnectionString"]; var conn = new CrmServiceClient(connectionString); |
value of conn.OrganizationServiceProxy was null and there was no specific exception thrown by the code.
While checking connection object only exception we saw was for LastCrmError object
LastCrmError “Unable to Login to Dynamics CRMOrganizationServiceProxy is null”
To resolve the issue we tried to change the authentication code to
1 |
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null); |
and got exception
Metadata contains a reference that cannot be resolved: ‘https://***.api.crm5.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9
While hunting for possible cause we came across Microsoft blog post stating that they have changed the connectivity to utilize TLS 1.2. (Default version used by .Net framework is SSL3 | TLS).
To enforce TLS 1.2 we included
1 |
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; |
just before connection request being sent to CRM. Tesolved issue in both authentication methods.