WCF服务:调用者未通过服务进行身份验证

时间:2013-08-19 12:22:21

标签: asp.net wcf web-services dynamics-crm-2011 dynamics-crm

编辑:发现问题,问题未解决。

我目前正在编写一个WCF服务库来访问Dynamics CRM 2011服务器以收集可见组织的列表。

代码在本地运行良好,但是在控制台应用程序中访问服务时,我收到以下错误:

System.ServiceModel.Security.SecurityNegotiationException: The caller was not authenticated by the service. ---> System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed.
   at System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target)
   at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)
   --- End of inner exception stack trace ---

Server stack trace:
   at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
   at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpantimeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.Discovery.IDiscoveryService.Execute(DiscoveryRequest request)
   at Microsoft.Xrm.Sdk.Client.DiscoveryServiceProxy.Execute(DiscoveryRequest request)
   at DHDServ.DHDServ.GetData(String serverName)
Press any key to continue . . .

我正在使用活动目录/ Windows身份验证并阻止匿名用户(该服务托管在Windows Server 2008上,但将由其他计算机访问)。由于经验不足,web.config文件仍然非常准确(来自Visual Studio 2010模板)。

非常感谢任何帮助。如果您需要更多信息,请询问,我会尽快回复。

谢谢, 杰森

2 个答案:

答案 0 :(得分:1)

确保您正在运行命令行的Windows用户是活动用户,并且在CRM中至少有一个角色。还要确保安装了WIF

答案 1 :(得分:0)

我们的服务器连接似乎存在问题。

由于我们的服务器设置方式,它不能很好地处理'双跳' - 导致Kerberos身份验证错误。

我们尚未解决此错误,但这篇文章只是为了让您知道问题已解决。

感谢所有帮助过的人:)