HTTP请求未经客户端身份验证方案“匿名"授权.从服务器收到的身份验证标头 [英] The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the serv

查看:114
本文介绍了HTTP请求未经客户端身份验证方案“匿名"授权.从服务器收到的身份验证标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..

WCF的新功能.

我遇到以下情况..我的WCF服务需要返回

I got following scenario .. my WCF service need to return

HttpContext .Current.Application [ ; auth_mode"; ] .ToString();

HttpContext.Current.Application["auth_mode"].ToString();

连接到WCF客户端.

我的服务显示为

命名空间 Calumo.Site.WCF

namespace Calumo.Site.WCF

{

//注意:如果您更改类名称"ExcelClientAuthentication",在这里,您还必须更新对"ExcelClientAuthentication"的引用,在Web.config中.

// NOTE: If you change the class name "ExcelClientAuthentication" here, you must also update the reference to "ExcelClientAuthentication" in Web.config.

[ AspNetCompatibilityRequirements (RequirementsMode = AspNetCompatibilityRequirementsMode .允许)]

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

公共 类别 ExcelClientAuthentication : IExcelClientAuthentication

public class ExcelClientAuthentication : IExcelClientAuthentication

{

公共 字符串 AuthenticateExcelClient()

public string AuthenticateExcelClient()

{

var test = OperationContext .Current.ServiceSecurityContext.WindowsIdentity;

var test = OperationContext.Current.ServiceSecurityContext.WindowsIdentity;

var application = HttpContext .Current.Application [ ; auth_mode"; ].ToString();

var application = HttpContext.Current.Application["auth_mode"].ToString();

返回 应用程序;

return application;

}

}

}

< system.serviceModel >

<system.serviceModel>

< serviceHostingEnvironment aspNetCompatibilityEnabled = " " >

<serviceHostingEnvironment aspNetCompatibilityEnabled="True">

</ serviceHostingEnvironment >

</serviceHostingEnvironment>

< 服务 >

<services>

< 服务 behaviorConfiguration = " Calumo.Site.WCF.ExcelClientAuthenticationBehavior "

<service behaviorConfiguration="Calumo.Site.WCF.ExcelClientAuthenticationBehavior"

名称 = " Calumo.Site.WCF.ExcelClientAuthentication " >

name="Calumo.Site.WCF.ExcelClientAuthentication">

<!- 服务端点 ->

<!-- Service Endpoints -->

< 端点 地址 = "" 绑定 = " wsHttpBinding " 合同 = " Calumo.Site.WCF.IExcelClientAuthentication " >

<endpoint address="" binding="wsHttpBinding" contract="Calumo.Site.WCF.IExcelClientAuthentication">

<!-

<!--

部署后,应删除或替换以下标识元素以反映

Upon deployment, the following identity element should be removed or replaced to reflect the

运行已部署服务的身份.如果删除,WCF将推断出适当的身份

identity under which the deployed service runs. If removed, WCF will infer an appropriate identity

自动.

->

-->

< 身份 >

<identity>

< dns = " 本地主机 " />

<dns value="localhost"/>

</ 身份 >

</identity>

</ 端点 >

</endpoint>

< 端点 地址 = " mex " 绑定 = " mexHttpBinding " 合约 = " IMetadataExchange " <字体color =#0000ff" size = 4>/>

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

</ 服务 >

</service>

</ 服务 >

</services>

< 行为 >

<behaviors>

< serviceBehaviors >

<serviceBehaviors>

< 行为 名称 = " Calumo.Site.WCF.ExcelClientAuthenticationBehavior " >

<behavior name="Calumo.Site.WCF.ExcelClientAuthenticationBehavior">

<!- 为避免泄露元数据信息,请在部署之前将下面的值设置为false并删除上面的元数据端点 ->

<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->

< serviceMetadata httpGetEnabled = " true " />

<serviceMetadata httpGetEnabled="true"/>

<!- 要在故障中接收异常详细信息以进行调试,请将下面的值设置为true.部署前设置为false以避免泄露异常信息 ->

<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->

< serviceDebug includeExceptionDetailInFaults = " false " />

<serviceDebug includeExceptionDetailInFaults="false"/>

</ 行为 >

</behavior>

</ serviceBehaviors >

</serviceBehaviors>

</ 行为 >

</behaviors>

</ system.serviceModel >

</system.serviceModel>

客户端:

命名空间 WindowsFormsApplication4

{

公共 部分 class Form1 : 表单

public partial class Form1 : Form

{

公共 Form1()

public Form1()

{

InitializeComponent();

InitializeComponent();

}

私有 无效 Form1_Load( 对象 发件人, EventArgs e)

private void Form1_Load(object sender, EventArgs e)

{

ExcelClientAuthenticationClient excelClient = ExcelClientAuthenticationClient ();

ExcelClientAuthenticationClient excelClient = new ExcelClientAuthenticationClient();

MessageBox .Show(excelClient.AuthenticateExcelClient()+ "" + client.GetData());

MessageBox.Show(excelClient.AuthenticateExcelClient()+" " +client.GetData());

}

}

}

但在 excelClient.AuthenticateExcelClient()-

错误:HTTP请求未经客户端身份验证方案匿名"授权.从服务器收到的身份验证标头是"Negotiate,NTLM".

error: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.

非常感谢您的帮助.

Ven

推荐答案

我遇到了相同的调试问题.


HTTP请求未经客户端身份验证方案'Anonymous'的授权.从服务器收到的身份验证标头是"NTLM",用于localhost

这是堆栈跟踪.

我正在使用基本的http绑定;服务和客户端都在Win 2008上运行服务器

"\ r \ n服务器堆栈跟踪:\ r \ n在System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest请求,HttpWebResponse响应,WebException responseException,HttpChannelFactory工厂)在系统中. ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest请求,HttpWebResponse响应,HttpChannelFactory工厂,WebException responseException)在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)\ r \ n在系统中. .Channels.RequestChannel.Request(消息,TimeSpan超时)\ r \ n在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息,TimeSpan超时)\ r \ n在System.ServiceModel.Channels. ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)\ r \ n在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime操作, System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime operation)的对象[] ins,Object [] outs)\ r \ n在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)\ r \ n r \ n \ r \ nException在[0]处重新抛出:\ r \ n在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)\ r \ n在System.Runtime.Remoting.Proxies.RealProxy .PrivateInvoke(MessageData& msgData,Int32类型)\ r \ n在IService.GetAvailableLocations()\ r \ n在ServiceClient.GetAvailableLocations()在C:\\ Users \\ RMircea \\ Documents \\ Visual Studio 2008 \\ Projects \\ WCFTest \\ WCFTest \\ Service.cs:行1626 \ r \ n在C:\\ Users \ RMircea \\ Documents \\ Visual Studio 2008 \\ Projects \\ WCFTest \\中的WCFTest.Program.Main(String [] args) WCFTest \\ Program.cs:行14 \ r \ n在System.AppDomain._nExecuteAssembly(装配体,String [] args)\ r \ n在System.AppDomain.ExecuteAssembly(String assemblyFile,证据assemblySecurity,String [] args) \ r \ n在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\ r \ n在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)\ r \ n在System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态)\ r \ n(位于System.Threading.ThreadHelper.ThreadStart()")

任何帮助将不胜感激
i get the same problem for debugging.


The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM', for localhost

here is the stack trace.

i am using basic http binding;the service and the client are both runing on Win 2008 Server

"\r\nServer stack trace: \r\n   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)\r\n   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)\r\n   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)\r\n   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)\r\n   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n   at IService.GetAvailableLocations()\r\n   at ServiceClient.GetAvailableLocations() in C:\\Users\\RMircea\\Documents\\Visual Studio 2008\\Projects\\WCFTest\\WCFTest\\Service.cs:line 1626\r\n   at WCFTest.Program.Main(String[] args) in C:\\Users\\RMircea\\Documents\\Visual Studio 2008\\Projects\\WCFTest\\WCFTest\\Program.cs:line 14\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"

any help would be appreciated


这篇关于HTTP请求未经客户端身份验证方案“匿名"授权.从服务器收到的身份验证标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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