Impersonating with a client caller identity
When using Windows authentication for either the transport layer or the message layer, the client authenticated user identity will be associated with the corresponding service operation context as a WindowsIdentity
instance. The service operation can check the name and roles of the identity, and in some cases we can also make the service operation code execute under the client authenticated user identity, which is commonly called identity impersonation. This recipe will demonstrate how we can perform client identity impersonation in a WCF service operation that uses a Windows authentication type.
Getting ready
Impersonation is quite common in distributed applications or component services (like ASP.NET, COM+, Web Service, and so on). You can get more information about impersonation in the following MSDN reference:
How To: Use Impersonation and Delegation in ASP.NET 2.0
How to do it...
In WCF, we...