简体   繁体   English

HTTP请求未经授权使用客户端身份验证方案“Negotiate”。从服务器收到的身份验证标头是'NTLM'

[英]The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'

Few days ago I had quite a headache with authentication problems when using Windows authentication between client and wcf web service . 几天前, 在客户端和wcf Web服务之间使用Windows身份验证时,我对身份验证问题非常头疼。 The error I was getting was "The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was "NTLM". None of the solutions on stack worked because most of them were related to old methods. 我得到的错误是“HTTP请求未经授权使用客户端身份验证方案'协商'。从服务器收到的身份验证头是”NTLM“。堆栈上的解决方案都没有工作,因为大多数解决方案都与旧方法有关。

THE ANSWER: The problem was all of the posts for such an issue were related to older kerberos and IIS issues where proxy credentials or AllowNTLM properties were helping. 回答:问题是这个问题的所有帖子都与旧的kerberos和IIS问题有关,其中代理凭证或AllowNTLM属性有帮助。 My case was different. 我的情况不同了。 What I have discovered after hours of picking worms from the ground was that somewhat IIS installation did not include Negotiate provider under IIS Windows authentication providers list. 我从地面挑选蠕虫数小时后发现的是IIS安装程序列表中的某些IIS安装不包括协商提供程序。 So I had to add it and move up. 所以我不得不添加它并向上移动。 My WCF service started to authenticate as expected. 我的WCF服务开始按预期进行身份验证。 Here is the screenshot how it should look if you are using Windows authentication with Anonymous auth OFF . 下面是截图,如果您使用匿名身份验证关闭的Windows身份验证,它应该如何。

You need to right click on Windows authentication and choose providers menu item. 您需要右键单击Windows身份验证并选择提供程序菜单项。

在此输入图像描述

Hope this helps to save some time. 希望这有助于节省一些时间。

I have upgraded my older version of WCF to WCF 4 with below changes, hope you can also make the similar changes. 我已经将我的旧版本的WCF升级到WCF 4并进行了以下更改,希望您也可以进行类似的更改。

1. Web.config: 1. Web.config:

<system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="Demo_BasicHttp">
            <security mode="TransportCredentialOnly">
              <transport clientCredentialType="InheritedFromHost"/>
            </security>
          </binding>
        </basicHttpBinding>
      </bindings>
      <services>
        <service name="DemoServices.CalculatorService.ServiceImplementation.CalculatorService" behaviorConfiguration="Demo_ServiceBehavior">
          <endpoint address="" binding="basicHttpBinding"
              bindingConfiguration="Demo_BasicHttp" contract="DemoServices.CalculatorService.ServiceContracts.ICalculatorServiceContract">
            <identity>
              <dns value="localhost"/>
            </identity>
          </endpoint>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="Demo_ServiceBehavior">
            <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
            <!-- 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"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
      <protocolMapping>
        <add scheme="http" binding="basicHttpBinding" bindingConfiguration="Demo_BasicHttp"/>
      </protocolMapping>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>

2. App.config: 2. App.config:

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ICalculatorServiceContract" maxBufferSize="2147483647" maxBufferPoolSize="33554432" maxReceivedMessageSize="2147483647" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="4096" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:24357/CalculatorService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICalculatorServiceContract" contract="ICalculatorServiceContract" name="Demo_BasicHttp" />
    </client>
  </system.serviceModel>

For me the solution was besides using "Ntlm" as credential type: 对我来说,解决方案除了使用“Ntlm”作为凭证类型:

    XxxSoapClient xxxClient = new XxxSoapClient();
    ApplyCredentials(userName, password, xxxClient.ClientCredentials);

    private static void ApplyCredentials(string userName, string password, ClientCredentials clientCredentials)
    {
        clientCredentials.UserName.UserName = userName;
        clientCredentials.UserName.Password = password;
        clientCredentials.Windows.ClientCredential.UserName = userName;
        clientCredentials.Windows.ClientCredential.Password = password;
        clientCredentials.Windows.AllowNtlm = true;
        clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
    }  

Not this exact problem, but this is the top result when googling for almost the exact same error : 这不是确切的问题,但这是谷歌搜索几乎完全相同的错误时的最高结果:

If you see this problem calling a WCF Service hosted on the same machine, you may need to populate the BackConnectionHostNames registry key 如果您在同一台计算机上调用托管WCF服务时遇到此问题,则可能需要填充BackConnectionHostNames注册表项

  1. In regedit, locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\MSV1_0 在注册表中,找到并单击以下注册表子项: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\MSV1_0
  2. Right-click MSV1_0 , point to New, and then click Multi-String Value . 右键单击“ MSV1_0 ,指向“新建”,然后单击“ Multi-String Value
  3. In the Name column, type BackConnectionHostNames , and then press ENTER. 在“名称”列中,键入BackConnectionHostNames ,然后按Enter。
  4. Right-click BackConnectionHostNames , and then click Modify. 右键单击“ BackConnectionHostNames ,然后单击“修改”。 In the Value data box, type the CNAME or the DNS alias, that is used for the local shares on the computer, and then click OK. 在“数值数据”框中,键入用于计算机上本地共享的CNAME或DNS别名,然后单击“确定”。
    • Type each host name on a separate line. 在单独的行上键入每个主机名。

See Calling WCF service hosted in IIS on the same machine as client throws authentication error for details. 有关详细信息,请参阅在客户机所在的同一台计算机上调用IIS中托管的WCF服务

I had the same problem, to solve it set specific user from domain in iis -> action sidebar->Basic Settings -> Connect as... -> specific user 我有同样的问题,要解决它在iis中设置域的特定用户 - >动作侧边栏 - >基本设置 - >连接为... - >特定用户

在此输入图像描述

我的解决方案是将AppPool设置为使用AppPoolIdentity到NetworkService身份。

暂无
暂无

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

相关问题 HTTP请求未经授权使用客户端身份验证方案&#39;Ntlm&#39;。 从服务器收到的身份验证标头是“Negotiate,NTLM” - The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM' 使用客户端身份验证方案“ Ntlm”对HTTP请求进行了未授权。从服务器收到的身份验证标头为“ NTLM” - The HTTP request is unauthorized with client authentication scheme 'Ntlm' The authentication header received from the server was 'NTLM' HTTP请求未经授权使用客户端身份验证方案“Negotiate”。 身份验证标头 - The HTTP request is unauthorized with client authentication scheme 'Negotiate'. the authentication header 客户端身份验证方案“匿名”未授权HTTP请求。 从服务器收到的身份验证标头 - The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server 客户端身份验证方案“匿名”未授权HTTP请求。 从服务器收到的身份验证标头为“基本” - The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic HTTP 请求未经授权,客户端身份验证方案为“匿名”。 从服务器收到的身份验证标头是“基本领域” - The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic Realm’ HTTP 请求未经客户端身份验证方案“Ntlm”授权 - The HTTP request is unauthorized with client authentication scheme 'Ntlm' 客户端身份验证方案&#39;Negotiate&#39;-从服务器收到的身份验证标头是&#39;Basic realm = \\“ EJBWebServiceEndpointServlet Realm \\”&#39; - Client authentication scheme 'Negotiate' - The authentication header received from the server was 'Basic realm=\“EJBWebServiceEndpointServlet Realm\”' 客户端身份验证方案“ Ntlm”不允许HTTP请求 - HTTP request is not allowed for client authentication scheme “Ntlm” 呼叫清单.asmx取得&#39;http要求是未经授权的客户端身份验证方案&#39;ntlm&#39; - call lists.asmx getting 'http request is unauthorized with client authentication scheme 'ntlm'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM