title: Calling WCF service with NTLM auth from .NET Core on linux
body: <p>I am unable to successfully call a WCF service with NTLM authentication from .NET Core running on a linux box (docker container).
  The same code works perfectly on Windows 10 though.</p>
  
  <p>What I have done:</p>
  
  <ul>
  <li>Add this to <code>ConfigureServices</code>:</li>
  </ul>
  
  <pre class="lang-cs prettyprint-override"><code>AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
  </code></pre>
  
  <ul>
  <li>Run <code>apt-get -y install gss-ntlmssp</code></li>
  <li>This is the code prior to calling the service:</li>
  </ul>
  
  <pre class="lang-cs prettyprint-override"><code>var client = new WcfServiceSoapClient();
  client.Endpoint.Address = new EndpointAddress(settings.Uri);
  client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
  client.ClientCredentials.Windows.ClientCredential = new NetworkCredential
  {
      Domain = settings.Domain,
      UserName = settings.Username,
      Password = settings.Password
  };
  var binding = (BasicHttpBinding)client.Endpoint.Binding;
  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
  </code></pre>
  
  <p>As mentioned this works fine on Windows 10. On Linux the following error is logged:</p>
  
  <pre class="lang-cs prettyprint-override"><code>System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM, Negotiate'.
     at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.&lt;&gt;c__DisplayClass1_0.&lt;CreateGenericTask&gt;b__0(IAsyncResult asyncResult)
  </code></pre>
  
  <p>Question is: why is it still failing on linux?</p>