2

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:

<system.net>
            <defaultProxy useDefaultCredentials=”true”&gt;
                <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?

4

1 回答 1

11

这是连接到 CRM Online 的最简单方法,您只需添加参考Microsoft.Xrm.Sdk.ClientMicrosoft.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); 

请参阅此 msdn 文章以创建正确的连接字符串

与 Microsoft Dynamics CRM 的简化连接

于 2013-04-10T15:38:34.773 回答