2

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.

BennoDual
  • 5,865
  • 15
  • 67
  • 153
  • Please see this article: http://stackoverflow.com/questions/1292183/what-value-should-the-serviceprincipalname-have – Glenn Ferrie Jan 14 '14 at 17:41

2 Answers2

1

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.

fejesjoco
  • 11,763
  • 3
  • 35
  • 65
  • Hi fejesjoco - I use custom principal. The idea with message inspector sound very interesting. Can you give me a sample how work with message insepctors? – BennoDual Jan 14 '14 at 18:09
  • This seems like a good example: http://adilmughal.com/blog/2011/10/client-additional-parameters-using-custom-headers-in-wcf/ – fejesjoco Jan 14 '14 at 19:51
  • The good thing about this approach is that you can send any kind of complex data contract object, and you can simply apply it to every call of a service, there's no need to add a new parameter to every service method one by one. – fejesjoco Jan 14 '14 at 19:54
0

this will be done implicitly as each request in WCF should have it's Iprincipal.Identity have you tried something like this in your server side

IPrincipal principal =   Thread.CurrentPrincipal;
BRAHIM Kamel
  • 13,492
  • 1
  • 36
  • 47