tags:

views:

13

answers:

1

In the constructor of my WCF service class I am setting the current principal to be that of the principal passed in the header of the message:

Thread.CurrentPrincipal = OperationContext.Current.IncomingMessageHeaders.GetHeader<BBPrincipal>("bbPrincipal", "ns");

This seems to work fine, however when I come to reference the principal in a method, the Thread.CurrentPrincipal has reverted to a WindowsPrincipal.

Presumably the method is firing on a different thread. How can I ensure that the method is using the principal set in the constructor of the service?

A: 

WCF always sets principal in AuthorizationPolicy so it probably overwrites your changes. You should implement custom authorization policy and set principal there.

Ladislav Mrnka