简体   繁体   English

调用 SAP PI Web 服务时,HTTP 请求未经客户端身份验证方案“Ntlm”授权

[英]The HTTP request is unauthorized with client authentication scheme 'Ntlm' while calling SAP PI web service

I am currently creating a .net C# service which uses webservice invoking to send information from CRM 2011 to SAP.我目前正在创建一个 .net C# 服务,它使用 webservice 调用将信息从 CRM 2011 发送到 SAP。

The credentials are said as following:凭证如下:

((BasicHttpBinding)defaultBinding).Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
((BasicHttpBinding)defaultBinding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; //.Ntlm;

PropertyInfo piClientCreds = type.GetProperty("ClientCredentials");
ClientCredentials creds = (ClientCredentials)piClientCreds.GetValue(obj, null);
PropertyInfo piWindowsCreds = creds.GetType().GetProperty("Windows");
WindowsClientCredential windowsCreds = (WindowsClientCredential)piWindowsCreds.GetValue(creds, null);
PropertyInfo piAllowNtlm = windowsCreds.GetType().GetProperty("AllowNtlm");
piAllowNtlm.SetValue(windowsCreds, true, null);
PropertyInfo piCredentials = windowsCreds.GetType().GetProperty("ClientCredential");
piCredentials.SetValue(windowsCreds, credentials, null);
PropertyInfo piImpersonation = windowsCreds.GetType().GetProperty("AllowedImpersonationLevel");
piImpersonation.SetValue(windowsCreds, System.Security.Principal.TokenImpersonationLevel.Impersonation, null);

The error I get is:我得到的错误是:

{System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Ntlm'. {System.ServiceModel.Security.MessageSecurityException:HTTP 请求未经客户端身份验证方案“Ntlm”授权。 The authentication header received from the server was 'Basic realm="Upload Protected Area"'.从服务器收到的身份验证标头是“基本领域=“上传保护区””。 ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. ---> System.Net.WebException:远程服务器返回错误:(401) 未经授权。 at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace ---在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- 内部异常堆栈跟踪结束---

Any help in resolving this and if possible making it dynamic is much appreciated.非常感谢解决此问题的任何帮助,并在可能的情况下使其动态化。

Thank you in advanced.先谢谢了。

The problem is quite obvious.问题很明显。 The server expects the your client to use Basic authentication while your client attempts to authenticate using NTLM.服务器希望您的客户端使用基本身份验证,而您的客户端尝试使用 NTLM 进行身份验证。 Try authenticating using UserNamePasswordClientCredential .尝试使用UserNamePasswordClientCredential 进行身份验证。 You should do this only over a secure transport such as HTTPS.您应该仅通过安全传输(例如 HTTPS)执行此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP 请求未经客户端身份验证方案“Ntlm”授权 - The HTTP request is unauthorized with client authentication scheme 'Ntlm' 使用客户端身份验证方案“ Ntlm”对HTTP请求进行了未授权。从服务器收到的身份验证标头为“ NTLM” - The HTTP request is unauthorized with client authentication scheme 'Ntlm' The authentication header received from the server was 'NTLM' HTTP请求未经授权使用客户端身份验证方案'Ntlm'。 从服务器收到的身份验证标头是“Negotiate,NTLM” - The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM' HTTP请求未经授权使用客户端身份验证方案“Negotiate”。从服务器收到的身份验证标头是'NTLM' - The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM' 客户端身份验证方案“ Ntlm”不允许HTTP请求 - HTTP request is not allowed for client authentication scheme “Ntlm” Wcf服务异常“使用客户端身份验证方案未授权HTTP请求” - Wcf service exception “The HTTP request is unauthorized with client authentication scheme” 呼叫清单.asmx取得'http要求是未经授权的客户端身份验证方案'ntlm' - call lists.asmx getting 'http request is unauthorized with client authentication scheme 'ntlm' 带有 .NET 核心的 SSRS 报告,HTTP 请求未经客户端身份验证方案“Ntlm”授权 - SSRS report with .NET Core, The HTTP request is unauthorized with client authentication scheme 'Ntlm' 使用客户端身份验证方案“匿名”对HTTP请求进行未经授权的授权? - The HTTP request is unauthorized with client authentication scheme 'Anonymous'? 计划摘要未授权Web服务HTTP请求 - Web service HTTP request is unauthorized with scheme digest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM