title: Asp.net Web api2 impersonate on webClient call
body: <p>we have a web api what has is how user account let's say <code>ApplicationPoolUser</code>
  that used have access to the databases used by the api, etc which work fine.</p>
  
  <p>but i'm trying to send a http get method on files on a remote server(sharepoint 2007) using <code>webClient</code></p>
  
  <p>here's what im using :</p>
  
  <pre><code>            WindowsImpersonationContext impersonationContext = null;
              Uri uri = new Uri(Path.Combine(this.Document.path , Document.fileNameOriginal));
              Stream stream = null;
  
  // WindowsIdentity.GetCurrent().Name return 'ApplicationPoolUser'
                  try
                  {
                      WindowsIdentity wi = System.Web.HttpContext.Current.Request.LogonUserIdentity;
                      impersonationContext = WindowsIdentity.Impersonate(wi.Token); 
  // WindowsIdentity.GetCurrent().Name return 'CurrentRequestingUser'
  
                  WebClient client = new WebClient() { 
                      UseDefaultCredentials = true,
                      CachePolicy = new System.Net.Cache.RequestCachePolicy(RequestCacheLevel.BypassCache)
                  };
  
                  stream = client.OpenRead(uri);
   // OpenRead Authentified on sharepoint server has ApplicationPoolUser
              }
              catch(WebException ex)
              {
                  HttpWebResponse webResp = (HttpWebResponse)ex.Response;
                  if(webResp.StatusCode == HttpStatusCode.NotFound)
                  throw new GeneralException(Common.Enums.ExceptionMessage.NotFound, webResp.StatusDescription);
                  else
                  {
                      throw ex;
                  }
              }
  </code></pre>
  
  <p>is there a way to force the authentification on behalf of the user without turning asp.net Identity ON ? in the web.config / IIS site. </p>
  
  <p>I dont want the whole code to execute has the impersonated user request just this small part ... </p>
  
  <p>I did try to use httpClient instead by i've found that since httpclient start in a new thread, it will always use the application pool identity.</p>
  
  <p>can i create the Negotiate Call myself and add it to the request ?</p>
  
  <p>thank you.</p>
  
  <p><strong>EDIT</strong> : 
  i have tried Removing all AuthenticationManager except Kerberos, and the request still use NTLM for authentication, what am i doing wrong ?</p>