2

We have a .Net WebApi Calling a Navision Soap service.

It works... except for sometimes, then suddenly for a couple of hours it starts returning Unauthorized, and then it returns back to normal... and starts working...

As the "Error info" describes, the scheme seems to be correct.

It is located on 2 different servers on the network(Read that having the 2 services on the same server, could cause problems).

SOAP IIS:

  • Anonymous Auth and Windows Auth is enabled.
  • SSL Certs are up to date
  • Nothing in Event Viewer to indicate an error.

Client/BasicHttpBinding:

  binding.Security.Mode = BasicHttpSecurityMode.Transport;
  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;


  client.ClientCredentials.Windows.ClientCredential.Domain = "domain.dk";
  client.ClientCredentials.Windows.ClientCredential.UserName = "username";
  client.ClientCredentials.Windows.ClientCredential.Password = "password";

Error message:

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

InnerException: The remote server returned an error: (401) Unauthorized.

  • It works... except for sometimes. So does this problem occur when you visit a specific page or during a specific period of time? Try to use failed request tracing to check when the error occur. – Bruce Zhang Nov 30 '21 at 06:24
  • It seems totally random when it starts to return 401. Ive tried comparing time of day, maybe something was running on the server or something. no avail. Will try to look into the "failed request tracing" on the IIS – Mathias Rønnow Nørtoft Nov 30 '21 at 06:32
  • 1
    what if u add : clientCredentials.Windows.AllowNtlm = true; clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; – Amjad S. Jan 31 '22 at 14:58

0 Answers0