So far I found out two solutions to get a WindowsIdentity object from a ClaimsIdentity. First I extract the user principal name (upn).
ClaimsIdentity ci = (ClaimsIdentity) Thread.CurrentPrincipal.Identity;
string upn = null;
foreach (Claim c in ci.Claims)
{
if (c.ClaimType == ClaimTypes.Upn)
{
upn = c.Value;
break;
}
}
Just call the constructor of WindowsIdentity with the upn:
WindowsIdentity winId = new WindowsIdentity(upn);
Use Claims to Windows Token Service (c2WTS):
WindowsIdentity winId = S4UClient.UpnLogon(upn);
Solution 1 seems for me the simpler and easier solution, but then i don't understand the purpose of the c2WTS?
Any suggestions?
tnx!