I am a total newbie with dynamics crm online (2011), and although I have been working through the SDK sample code, I am trying to find the simplest way to perform a basic authenticated connection to our online Dynamics CRM service, and push some very basic data to a custom entity/extension I have created.

code snippet

Hopefully you can see from the above code snippet (sensitive data blurred), I am probably trying to circumvent the authentication process? The above code example was based a little on some of the code samples in the CRM SDK, and also from a code project example. I don't know if the code above would even work? actually it seems to try, and only when the "serviceProxy.Create" is executed do I get an authentication error.

I have also managed to navigate out of the corporate firewall with the following addition to my app.config file:

            <defaultProxy useDefaultCredentials=”true”>
                <proxy usesystemdefault="true"/>   

Again, not sure if there is a very basic way to connect? or should I really fall back to the SDK helper files?


This is the simplest way to connect to CRM Online, you need only to add reference to Microsoft.Xrm.Sdk.Client and Microsoft.Xrm.Client.Services

CrmConnection crmConnection = CrmConnection.Parse("Url=https://XXX.crm.dynamics.com; Username=user@domain.onmicrosoft.com; Password=passwordhere;");
OrganizationService service = new OrganizationService(crmConnection);

Entity account = new Entity("account");
account ["name"] = "Test Account";

Guid accountId = service.Create(account); 

Refers to this msdn article for create the right connection string

Simplified Connection to Microsoft Dynamics CRM

  • Excellent! wow, so much more simple than a few other examples! obviously I understand for certain situations you might need other ways of connecting. So thanks so much, and just for completeness, I did need to add Microsoft.Xrm.Sdk to get to the Entity class. Also in my case, I had to add the DeviceID and DeviceID Password to the connection string.. my connection string has crm4 in it, where your example is "crm" so not sure if its a newer version etc? anyway, again many many thanks.. far easier than other solutions I have seen. – Dav.id Apr 11 '13 at 8:20
  • 3
    the connection string need to reflect your crm environment. the url can be crm, crm4 or crm5, depends in which region is your instance (North America, EMEA, APAC) and the device credentials are necessary if you are using windows live id authentication, with office365 authentication are not necessary. – Guido Preite Apr 11 '13 at 8:42

Your Answer

