我正在连接到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