简体   繁体   English

使用C#连接到Windows Form Application中的Dynamics CRM

[英]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. 在Windows窗体应用程序中,我需要使用C#对用户进行身份验证,然后让该用户对Case实体执行CRUD操作。

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. 您似乎将URL指向组织Web服务。 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. 以下URL会建议连接字符串的正确格式是什么,因为它将根据您连接到CRM Online或本地版本以及版本而改变。

https://msdn.microsoft.com/en-us/library/gg695810(v=crm.6).aspx https://msdn.microsoft.com/zh-CN/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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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