1

VS2010 で WCF サービスを使用しています。

私のクライアント側では、Thread.CurrentPrincipal に、IPrincipal を実装するカスタマイズされたプリンシパル オブジェクトが取り込まれます。

ただし、WCF サービス メソッドが呼び出されると、サービス側の Thread.CurrentPrinicpal は既定の WindowsPrincipal になります。

サービス側の Thread.CurrentPrincipal をクライアント側 (カスタマイズされたプリンシパル オブジェクト) と同じにするにはどうすればよいですか?

助けてください。

ありがとう

4

1 に答える 1

1

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 http://burcakcakiroglu.com/?p=2189) 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"].

于 2012-09-07T14:52:23.710 に答える