问题
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.

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:
<system.net>
<defaultProxy useDefaultCredentials=”true”>
<proxy usesystemdefault="true"/>
</defaultProxy>
</system.net>
Again, not sure if there is a very basic way to connect? or should I really fall back to the SDK helper files?
回答1:
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
来源:https://stackoverflow.com/questions/15929879/ms-dynamics-crm-online-2011-authentication-issues