简体   繁体   中英

Connect to Dynamics CRM in Windows Form Application using C#

In windows form application, I need to authenticate a user using C# and then let the user to perform CRUD operations on Case entity.

I tried following code snippet to authenticate but didn't worked. Any guidelines to do it work.

CrmConnection connection = CrmConnection.Parse("Url=" + org + "/XRMServices/2011/Organization.svc; Username=" + username + "; Password=" + password + ";");
            OrganizationService service = new OrganizationService(connection);

It looks like you are pointing the URL to the Organization Web Service. I would suggest that this needs to be changed.

The following URL advises what the correct format is for the connection string, as the it will change depending if you are connecting to CRM Online or On-Premise and on versions.

https://msdn.microsoft.com/en-us/library/gg695810(v=crm.6).aspx

using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk;

IOrganizationService organizationService = null;
string connectionString = string.Format(@"Url={Your url from IP:port/Organization}; Domain={Your Domain}; Username={User name}; Password={Password}");
Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(connectionString);
organizationService = new Microsoft.Xrm.Client.Services.OrganizationService(connection);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM