【问题标题】:Connect to MS Dynamics CRM 2011 Desktop CrmConnection连接到 MS Dynamics CRM 2011 桌面 CrmConnection
【发布时间】:2016-12-23 19:14:49
【问题描述】:

我的客户正在使用 Dynamics CRM 2011 的托管版本,而不是在线版本。使用我的 C# 代码,我将如何获取用户名、密码、URL 和设备 ID 以进行身份​​验证?在线使用 CRM 2011,我可以使用此代码进行连接。我相信设备 ID 是硬编码的。

CrmConnection crmConnection = CrmConnection.Parse(String.Format("Url={0}; Username={1}; Password=   
{2};DeviceID=enterprise-ba9f6b7b2e6d; DevicePassword=passcode;", url, username, password));

OrganizationService service = new OrganizationService(crmConnection);
var xrm = new XrmServiceContext(service);
return xrm;

【问题讨论】:

    标签: c# dynamics-crm-2011


    【解决方案1】:

    托管版本 (OnPremise) 依赖于 Active Directory 身份验证 (DOMAIN\USERNAME),因此您需要将 Domain 添加到您的连接字符串并删除 DeviceIDDevicePassword(它们仅对于使用 LiveId 的 CRM Online 是必需的认证)

    代码将是:

    CrmConnection crmConnection =
    CrmConnection.Parse(String.Format("Url={0}; Username={1}; Password={2}; Domain={3}", url, username, password, domain));
    

    【讨论】:

      【解决方案2】:

      尝试删除 deviceid 和 devicepassword。另请查看描述如何使用 CrmConnection 类的this article

      【讨论】:

        【解决方案3】:
        ClientCredentials Credentials = new ClientCredentials();
        Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
        

        /此 URL 需要与环境的服务器名称和组织相匹配。

        Uri OrganizationUri = new Uri("http://crm/XRMServices/2011/Organization.svc");
        Uri HomeRealmUri = null;
        
        using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
        {
        
            IOrganizationService service = (IOrganizationService)serviceProxy;
            if (Context.User.Identity.IsAuthenticated)
               {
                 string EUserName = Context.User.Identity.Name;
                  string WinUserName = WindowsIdentity.GetCurrent().Name;
                  UserName.InnerText = EUserName;
               }
        }
        
        
        Also add references
        **microsoft.crm.sdk.proxy**
        **microsoft.xrm.sdk**
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-05-21
          • 2011-12-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-01-11
          • 1970-01-01
          相关资源
          最近更新 更多