title: How to use LogonUser properly to impersonate domain user from workgroup client
body: <p><a href="https://stackoverflow.com/questions/278132/asp-net-impersonate-against-a-domain-on-vmware">ASP.NET: Impersonate against a domain on VMWare</a></p>
  
  <p>This question is what I am asking, but the answer does not provide details on how the _token is derived. It seems to only use <code>WindowsIdentity.GetCurrent().Token</code> so there's no impersonation happening.</p>
  
  <p><a href="https://stackoverflow.com/questions/997001/can-i-impersonate-a-user-on-a-different-active-directory-domain-in-net">Can I impersonate a user on a different Active Directory domain in .NET?</a></p>
  
  <p>This next question has conflicting answers, with the accepted one bearing a comment "I'm beginning to suspect that my problem lies elsewhere."  Not helpful.</p>
  
  <p><a href="https://stackoverflow.com/questions/993418/logonuser-works-only-for-my-domain">LogonUser works only for my domain</a></p>
  
  <p>This next question seems to imply it is not possible, but it deals with 2 domains so I am not sure if it is relevant.</p>
  
  <p>My real question is:</p>
  
  <ul>
  <li><strong>Is it possible?</strong> And if so,</li>
  <li><strong>How?</strong> or <strong>Where did I go wrong?</strong></li>
  </ul>
  
  <p>What I have tried so far is, using the code from <a href="http://msdn.microsoft.com/en-us/library/chf6fbt4%28v=VS.80%29.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/chf6fbt4%28v=VS.80%29.aspx</a></p>
  
  <pre><code>bool returnValue = LogonUser(user, domain, password,
              LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT,
              ref tokenHandle);
  // after this point, returnValue = false
  </code></pre>
  
  <p>The Win32 error is</p>
  
  <blockquote>
    <p>Logon failure: unknown user name or bad password</p>
  </blockquote>