0

我编写了应用程序由 c# 形式编写的代码 application.crm 使用 ssl 运行。

      ClientCredentials credential = new ClientCredentials(); 
      credential.Windows.ClientCredential = new 
      System.Net.NetworkCredential("username", "password", "domain"); 
      Uri organizationUri = new Uri("https://serverAdress/Orgname/XRMServices/2011/Organization.svc");
      Uri homeRealUri = null;
      serviceProxy = new OrganizationServiceProx
(organizationUri, homeRealUri, credential, null);
                                serviceProxy.EnableProxyTypes();

我也试过tihs版本。

>  ClientCredentials Credentials = new ClientCredentials(); 
>     Credentials.Windows.ClientCredential.UserName ="<username>"; 
>     Credentials.Windows.ClientCredential.Password ="<password>";

它不会抛出任何异常,但 serviceProxy 无法通过身份验证。如何解决?任何建议。

4

1 回答 1

0

老问题,但这是我的建议。

看看这里提供的示例代码:http: //msdn.microsoft.com/en-us/library/hh675404.aspx

只需更改以下条目以满足您的需要

    private String _discoveryServiceAddress = "https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc";
    private String _organizationUniqueName = "OrganizationUniqueName";
    // Provide your user name and password.
    private String _userName = "username@mydomain.com";
    private String _password = "password";

    // Provide domain name for the On-Premises org.
    private String _domain = "mydomain";

并且控制台应用程序应该打印出:登录的用户是“名字”“姓氏”。然后您可以从以下位置获取 OrganizationServiceProxy:

using (OrganizationServiceProxy organizationProxy =
                GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))

并使用它。

于 2013-12-05T18:32:08.460 回答