Search code examples
c#wcfc#-4.0wcf-security

Take principal from client to server in WCF-Service


In my Application, I create on Client-side my own Principal-Object, which i set like

Thread.CurrentPrincipal = myPrincipal;

Now, when I call a WCF-Service (TCP/IP), I should also have this Principal in the Server-side Thread of this called WCF-Service. Is there something that I can configure to do this, or does I have to implement this myself?

Thanks for your hints.


Solution

  • If we're talking about windows principals, look at WCF authentication and security options. It's not trivial.

    If you have a custom principal object, then my suggestion is to implement message inspectors, serialize the principal inside a message header and unpack it on the other side. This works pretty well for us in a number of projects, and doesn't require any special WCF settings.