2012-04-26 79 views
0

我寫代碼的應用程序是由C#形式application.crm與SSL運行的書面認證。C#CRM 2011呼叫者服務不

 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無法驗證。如何解決? 任何建議。

+0

您的用戶是否擁有應用程序級權限? – 2012-04-26 15:53:30

+2

我知道它可能在這裏顯而易見,但是您試圖連接到CRM服務的用戶實際上是CRM用戶(例如在同一個域中),且具有正確的權限?就如何連接到CRM服務而言,上面的代碼看起來不錯。 – 2012-04-26 15:58:22

+0

@ PhilipRich,該應用程序在服務器上安裝的crm上運行,用戶具有管理權限。 – engcmreng 2012-04-26 19:50:04

回答

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 = "[email protected]"; 
    private String _password = "password"; 

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

和控制檯應用程序應該打印出來:登錄的用戶是「名字」 「姓」。然後你可以從組織服務代理:

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

並使用它。