为什么在连接到Dynamics CRM元数据服务时出现401错误? [英] Why do I get 401 errors connecting to the Dynamics CRM Metadata service?

查看:103
本文介绍了为什么在连接到Dynamics CRM元数据服务时出现401错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在连接CRM,目的是检索选择列表值的列表。在开发计算机上,我以自己的登录名进行工作,并且一切正常。在测试服务器上,代码在NETWORK SERVICE帐户下执行。当它连接到CRM Web服务时,一切都很好。当它连接到元数据服务时,我会收到401条未授权的消息。

I am connecting to CRM with the intention of retrieving a list of picklist values. On my development machine I am working under my own login name and all works fine. On the test server, the code executes under the NETWORK SERVICE account. When it connects to the CRM web service everything is great. When it connects to the metadata service I get 401 Unauthorised messages.

这是我第一次使用元数据服务,因此我希望有人能告诉我为什么我得到了错误。使用下面的代码配置该连接,并且当您尝试检索选择列表数据时会失败。

This is the first time I have used the metadata service so I am hoping someone can tell me why I get the error. The connection is configured using the code below and the failure happens when you try to retrieve the picklist data.

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 /授权问题,确保它尝试用
新的System.Security.Net.NetworkCredentials( username, password, domain);替换DefaultCredentials;

I suspect it might be a Kerberos / delegation issue, to make sure it is try replacing DefaultCredentials with new System.Security.Net.NetworkCredentials("username","password","domain");

看看是否仍然可以找到401。

See if that still gives you a 401.

这是我通常尝试查看它是否与kerbos /安全性相关的一种快捷方法。

This is the quick way I normally try to see if it is kerbos/security related.

我需要有关您的环境的更多信息,以便进行其他任何明智的评论。

I need a bit more information about your environment to make any other intelligent comments.

希望有帮助。

这篇关于为什么在连接到Dynamics CRM元数据服务时出现401错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆