Carry over client side customized Principal object to the WCF service side

I am using WCF service on VS2010.

On my client side, Thread.CurrentPrincipal is populated with Customized Principal object which implements IPrincipal.

But when the WCF service method gets invoked, the Thread.CurrentPrinicpal on the service side is WindowsPrincipal which is the default.

How can I make the service side Thread.CurrentPrincipal same as the client side (Customized Principal object)?

Please help.



Here's one way, I don't know if there's a more easy way though:

You need an IEndpointBehaviour implementation that in the ApplyClientBehavior method attaches a custom message inspector which in turn adds a custom message header (in the BeforeSendRequest method) containing your custom principal instance. You might need to decorate your custom principal object with Data Contract attribute in order for it to serialize. Then, implement a custom authorization policy (similar to which will run at the server end and in the Evaluate method read the custom message header back out again and copy the principal in the header into evaluationContext.Properties["Principal"].

Need Your Help

dependencies of grails plugins

grails grails-plugin

I'm writing a Grails plugin that depends on the Quartz plugin, i.e. an application that installs my plugin must also install the Quartz plugin. In order to enforce this requirement, I added the fol...

wcf restful service config error

c# wcf rest

I'm creating a skeleton algorithm of a restful service showing how to handle post and get requests. from my example get is working fine, however post does not. i guess i should add stuff to web.con...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.