title: Using Windows Authenticated WCF services
body: <p>I have a Windows authenticated WCF service.</p>
  
  <p>Using the following configuration:</p>
  
  <pre><code>BasicHttpBinding binding = new BasicHttpBinding();
  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
  binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
  
  binding.SendTimeout = TimeSpan.FromMinutes(60);
  binding.CloseTimeout = TimeSpan.FromMinutes(60);
  binding.OpenTimeout = TimeSpan.FromMinutes(60);
  binding.ReceiveTimeout = TimeSpan.FromMinutes(60);
  
  NexumCrmServiceClient client = new NexumCrmServiceClient(binding, new EndpointAddress("http://xxxxxx:81/xxxxxxxxxxxxxx.svc"));
  client.ClientCredentials.Windows.AllowNtlm = true;
  //client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
  client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("xxxxxxxx", "xxxxxxxx", "xxxxxxxxx");
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>There was no endpoint listening at
    <a href="http://xxxxxx:81/xxxxxxxxxxxxxxxx.svc" rel="nofollow">http://xxxxxx:81/xxxxxxxxxxxxxxxx.svc</a> that could accept the message.
    This is often caused by an incorrect address or SOAP action. See
    InnerException, if present, for more details...</p>
  </blockquote>
  
  <p>And if I use the configuration below: </p>
  
  <pre><code>BasicHttpBinding binding = new BasicHttpBinding();
  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  
  binding.SendTimeout = TimeSpan.FromMinutes(60);
  binding.CloseTimeout = TimeSpan.FromMinutes(60);
  binding.OpenTimeout = TimeSpan.FromMinutes(60);
  binding.ReceiveTimeout = TimeSpan.FromMinutes(60);
  
  NexumCrmServiceClient client = new NexumCrmServiceClient(binding, new EndpointAddress("http://xxxxxx:81/xxxxxxxxxxxxxx.svc"));
  client.ClientCredentials.Windows.AllowNtlm = true;
  //client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
  client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("xxxxxxxx", "xxxxxxxx", "xxxxxxxxx");
  </code></pre>
  
  <p>I'm getting another error:</p>
  
  <blockquote>
    <p>The HTTP request is unauthorized with client authentication scheme
    'Anonymous'. The authentication header received from the server was
    'Negotiate,NTLM'.</p>
  </blockquote>
  
  <p>Would you please suggest a configuration that works successfully?</p>
  
  <p>Thanks in advance, </p>