我正在連接到CRM,目的是檢索選項列表值列表。在我的開發機器上,我正在使用我自己的登錄名,並且一切正常。在測試服務器上,代碼在NETWORK SERVICE帳戶下執行。當它連接到CRM網絡服務時,一切都非常棒。當它連接到元數據服務時,我收到401 Unauthorized消息。爲什麼我會連接到Dynamics CRM元數據服務的401錯誤?
這是我第一次使用元數據服務,所以我希望有人能告訴我爲什麼會出現錯誤。連接使用下面的代碼進行配置,當您嘗試檢索選項列表數據時發生失敗。
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = config.AppSettings.Settings["CrmTargetOrganisation"].Value;
token.AuthenticationType = 0;
MetadataService service = new MetadataService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Url = config.AppSettings.Settings["CrmMetadataServiceUrl"].Value;
service.CrmAuthenticationTokenValue = token;
service.UnsafeAuthenticatedConnectionSharing = true;
不幸的是,我不知道確切的修復,但我們的網絡人員在kerberos中整理了一些東西,現在它可以工作。 – BlackWasp 2009-01-07 14:52:10