6

With little knowledge of CRM, we were tasked with exposing data and other functionality from CRM 2011. We developed a RESTful wrapper that allows other developers to leverage it in their apps. Some example endpoints might have been:

API/v2/Accounts(someguid)
API/v2/Lead/Create {json object}
etc

This application needs to be upgraded to support dynamics 2016. We fired up our 2011 app, and simply changed a config variable to point to a 2016 instance. So far we haven't been able to do anything because right after the second line below:

        var context = new XrmServiceContext(_organizationService);

        var crmUser = (from systemUser in context.SystemUserSet
                       where systemUser.DomainName == user.DomainUserName
                       select systemUser).FirstOrDefault();

I get authentication failed exceptions:

enter image description here

Is this indeed a known authentication issue when upgrading from 11 to 16, or am I missing something?

Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • 2
    Please share the code you use to get _organizationService, because problem should be there. Also have you done any changes to your CRM configuration like IFD configuration? And also - was the user that you use to call CRM mapped as CRM user? In other words - can you still access CRM using this user? – Pawel Gradecki Mar 26 '17 at 21:55
  • 1
    There are minor differences in the response from the server when authenticating between CRM 2011 and CRM 2016 SP1, but once you update your DLLs you should be able to authenticate ok. As above, please share your code – jasonscript Mar 27 '17 at 00:43
  • @jasonscript update which DLLs? do you mean the sdk? if so, how do i do this? – Alex Gordon Mar 27 '17 at 00:46
  • You should be able to download the new sdk (or if you are using nuget, update your packages). Please show your connection code – jasonscript Mar 27 '17 at 01:01
  • @jasonscript there are no updates, however they have separate packages for 2016, shall i just uninstall 2011? – Alex Gordon Mar 27 '17 at 03:34
  • The SDK dlls are local to your code. If you upgrade they should be backward compatible. Also might be time to pull out fiddler. – SoftwareCarpenter Apr 06 '17 at 19:10
  • @jasonscript you mean update the sdk? what would i be updating? – Alex Gordon Apr 06 '17 at 19:58
  • 1
    In the code that is connecting to CRM you have reference dlls like Microsoft.Xrm.Sdk. These need to be updated to version 8.x from 5.x that you probably are using atm. – Rickard N Apr 19 '17 at 10:02
  • @RickardN there doesnt seem to be an automatic way to dothis. for example, nuget does not have any suggestions. do you? – Alex Gordon Apr 19 '17 at 14:42
  • 1
    Sure, if you're using nuget and have a package that has an upgrade with the latest dlls, Microsoft.CrmSdk.CoreAssemblies or something similar, then it's just to do a NuGet upgrade, if the packages you're using doesn't have an upgraded version then you have to do it manually or use a package that has the 8.X SDK dlls – Rickard N Apr 20 '17 at 11:43

1 Answers1

4

There have been countless Authenticate Changes between CRM 2011 and 2016. The SDK should handle all of these issues for you, fairly seamlessly.

Download the latest version from https://www.microsoft.com/en-us/download/details.aspx?id=50032, and update any of Microsoft.Xrm.* dlls that you are referencing in your project.

If you're using Nuget, you could add these instead:

  • Microsoft.CrmSdk.Extensions (7.1.0.1 - this contains the older connection method to CRM. It will be going away, but for now, is still compatible)
  • Microsoft.CrmSdk.Deployment (8.2.0.2)
  • Microsoft.CrmSdk.Workflow (8.2.0.0) --> This one should actually be optional.

Once you've updated your references, rebuild, and retry.

Daryl
  • 18,592
  • 9
  • 78
  • 145