Search code examples
dynamics-crmdynamics-365

D365 WS-Trust deprecation - Microsoft.Xrm.Client


I have a legacy application connected to cloud d365 that uses:

XrmServiceContext : Microsoft.Xrm.Client.CrmOrganizationServiceContext

from Microsoft.Xrm.Client namespace. It was downloaded from there back then. The connetion string looks like this:

"Url=https://org.api.crm4.dynamics.com/XRMServices/2011/Organization.svc;Username=unm;Password=pwd"

is the code affected by WS-Trust deprecation announced by MSFT?


Solution

  • Yes, definitely. You should switch to the following pattern:

    targetString = string.Format("AuthType=OAuth;Username={0}; Password={1};Url={2};AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Disabled;RequireNewInstance=true", CRMUsername, CRMPassword, CRMAddress);
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    

    Note that those are the "default" AppId and RedirectURI and that in production environments you should register your app and use production values.