runtime: Unable to use System.Net.NetworkCredential inside docker

I am trying to authenticate my call to a SSRS report server hosted outside the docker application. And to accress the report I do the following:

HttpWebRequest webRequest = WebRequest.Create(sTargetURL) as HttpWebRequest;
webRequest.Credentials = new NetworkCredential(strReportUser, strReportUserPW);
WebResponse HttpWResp = await webRequest.GetResponseAsync();

But I continuesly get 401 unauthorized.

The approach of NetworkCredentials works fine when I am doing the same inside my Azure Hosted App service and also my local.

The credentials that I set on the header inside the docker environment, simply do not carry forward upto the report server and I get the error.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 29 (12 by maintainers)

Most upvoted comments

No. After 4 hours i solved the issue. My Client runs inside a Linux container and i changed my code to this:

var httpClientHandler = new HttpClientHandler();

CredentialCache cc = new CredentialCache();
cc.Add(new Uri(_apiBaseAddress), "NTLM", new NetworkCredential(_user, _password, "mydomain"));
httpClientHandler.Credentials = cc;

var client = new HttpClient(httpClientHandler);

outside from docker on a windows shell i dont need the credentialCache so i passed the NetworkCredential object directly to the handler. But that dont worked in docker. Inside the container, the wget command response with 2 unauthorized exceptions but the next one with 200. I think some kind of handshaking. Maybe the Cache object do the job right and dont throw an exception on the first request.