Monday 11 February 2013

Connecting CRMSVCUTIL/External ASP.NET Application and CRM Online

The connection properties differ somewhat between connecting to CRM “On Premise” and CRM Online. The extra parameters required for CRM Online make up the difference, these being “Device ID” and “Device Password”. These are required as an extra security precaution for the online web services. So how do you get them? In order to get your very own device id and password you use the device registration executable in the SDK_Directory\Tools\deviceregistration\bin\debug directory (you will need to download the Dynamics CRM SDK and install it on your machine somewhere). You will need to open the deviceregistration Visual C# project and build it once in order to see the executable. Once this is done run the Device Registration exe from the command line, with the following parameters:
deviceregistration.exe /Operation:Register /Name:"123456789101" /Password:"123456789101"
The name and password are OPTIONAL. Here I am telling the device registration tool that I want my device name (ID) and password to specifically be this. If you leave them out it will generate a new device id/password automatically for you. Once it gives you these values these are what go into you connection string for your application. An example of this in a “CRM Online” connection string for an ASP.NET application:
<add name="Conn" connectionString="Url=https://CRM_ONLINE_URL; UserName=CRM_LOGIN(WLID/O365 ID); Password=XXXXX; Device ID=123456789101; Device Password=123456789101"/>

You do not however need the Device ID and Device Password for using CRMSVUTIL.
 
TROUBLESHOOTING
With regard to troubleshooting two issues I had and couldn’t find a resolution for online was an authentication issue: on CRMSVCUTIL the message was “Authentication Failure”: in this instance I had accidentally included the Device ID and Device Password parameters, and it doesn't like that. The other issue was a message from the ASP.NET website of “The device authentication failed!”. The second message is clearer as to what it has a problem with. At this point try running the Device Registration tool again with the Device ID/Password that you would like to use, and if you get a message along the lines of “device id already registered”, then this side of things is correct – your device is correctly registered. The issue in my case was the server time was out of sync with the CRM Online server. Mine was a full 10 minutes out, so setting it correctly and re-running the website resolved the issue.
Another issue I have seen is an incorrect locally stored device id profile. When you run the Device Registration tool it places an XML file with encrypted values in:
C:\%USERPROFILE%\LiveDeviceID
Delete the LiveDeviceID.xml file in here and re-run Device Registration, as per the instructions above.
Thanks,
Nick

No comments:

Post a Comment