title: Claims to windows token service impersonated token
body: <p>I have a claims based SharePoint 2010 website where I need to call out to a back end non-claims aware system (K2 blackpearl).</p>
  
  <p>So to achieve this I am attempting to use the claims to windows token service to impersonate the user as described <a href="http://msdn.microsoft.com/en-us/library/ee517278.aspx" rel="nofollow">here</a></p>
  
  <p>Now when calling the c2wts using a user UPN to convert to a claim using the following code:</p>
  
  <pre><code>WindowsIdentity windowsIdentity = null;
  SPSecurity.RunWithElevatedPrivileges(
  delegate()
  {
  windowsIdentity = S4UClient.UpnLogon("user@domain.com");
  });
  </code></pre>
  
  <p>Now when I impersonate that windowsIdentity.ImpersonationLevel is Identification rather than Impersonate</p>
  
  <pre><code>using (WindowsImpersonationContext c = windowsIdentity.Impersonate())
  {
  Debug.WriteLine(WindowsIdentity.GetCurrent().ImpersonationLevel); // returns Identification
  ConnectToK2();
  c.Undo();
  } 
  </code></pre>
  
  <p>This I think is what is causing the problem as when trying to call off to the service using the token it is failing.  The article mentioned above talks about getting a Impersonated token back but I am unable to do this.</p>
  
  <p>Does anyone know what I may be doing wrong?</p>
  
  <p>Thanks</p>