title: Calling ASMX Service from C# app with Windows authentication?
body: <p>I have created simple .NET Web Service (ASMX) that I call from my .NET web application.  The service and web app both use Windows Authetication.</p>
  
  <pre><code>com.mydomain.MyWebService webSrvc = new com.mydomain.MyWebService();
  string output = webSrvc.MyServiceMethod();
  </code></pre>
  
  <p>I am now creating Windows app with C#, and would like to call the same web service from there.  I have added a web reference in my project to the service, and I can make calls to the service web methods without issue.  The problem is, inside the web methods, I am trying to retrieve the user's windows user name.</p>
  
  <pre><code>string username = User.Identity.Name; //always blank
  </code></pre>
  
  <p>This works when I call the web service from my web app, but when I call it from my windows app, it always returns blank, and User.Identity.IsAuthenticated is always false, if that is relevant.  What am I missing here.  I just need to get the Windows user username that is running the console app, that called the web service.  I have tried setting the credentials of webSrvc to the ClientCache default credentials, but that doesn't solve the problem.</p>
  
  <p>UPDATE: I don't know if this is useful, but I learned that if I use Environment.UserName, it will give "NETWORK_SERVICE", and then if i enable impersonation, it will give "IUSR_[host_name]".  It seems like i'm just missing something really simple.  I just want to get the current windows user, who is running the windows app (which calls the web service).</p>