How to impersonate programmatically in WCF
Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen
To impersonate the original caller programmatically, you need to have access to Windows Identity of the original caller, calling into your WCF service. For this you need to configure your WCF service to require Windows Authentication. Programmatic impersonation
allows you to impersonate on specific lines of code rather than the entire operation.
Use the Impersonate
method of the ServiceSecurityContext.Current.WindowsIdentity
class, as shown here.
public string GetData(int value)
// Execute under security context of the original caller
: Revert the impersonation when you are done, in the above example the
statement does it for you.