Im using a transparent proxy to tunnel the frontend to the backoffice, but cant get the logged user even with personation activated.
GET Transparent Proxy:
[HttpGet, Route("api/{*url}")]
public HttpResponseMessage Get(string url)
{
var client = new WebClient { UseDefaultCredentials = true };
client.Headers.Add(HttpRequestHeader.ContentType, "application/json; charset=utf-8");
var result = JsonConvert.DeserializeObject<Object>(Encoding.UTF8.GetString(client.DownloadData(ConfigurationManager.AppSettings["InternalWebApiUrl"] + "/" + url)));
return Request.CreateResponse(result);
}
Any attempts on getting the logged user failed, i only get the ApplicationalPool User.
My attempts:
1- used IIS Configurations to activate impersonation, and added the follwing code to webconfig:
<authorization>
<allow users ="*" />
</authorization>
2- Created a GetCurrentUser service to test the credentials that were passed to the backend, but only the ApplicationalPool User showed up:
[HttpGet, ResponseType(typeof(string)), Route("GetCurrentUser")]
public HttpResponseMessage GetCurrentUser()
{
WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = winId.Impersonate();
var userHTTPContext = HttpContext.Current.User.Identity.Name;
var userThread = Thread.CurrentPrincipal.Identity.Name;
var userImpersonated = winId.Name;
return Request.CreateResponse("HTTP Context: " + userHTTPContext.ToString() + " Thread: " + userThread.ToString() + " Impersonated: " + userImpersonated.ToString());
}
How can i get the logged user?
Is it possible that im passing the ApplicationalPool User by using UseDefaultCredentials in the WebClient?