WCF サービスで偽装を実装するには
1) 以下のコードのように、操作を OperationBehavior で装飾し、"Impersonation = ImpersonationOption.Required" を指定します。
[ServiceContract]
public interface IHelloContract
{
[OperationContract]
string Hello(string message);
}
public class HelloService : IHelloService
{
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string Hello(string message)
{
return "hello";
}
}
2) クライアント側は以下のように呼び出します
using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
{
HelloService.ServiceClient myService = new HelloService.ServiceClient();
Console.WriteLine(myService.Hello("How are you?"));
myService.Close();
}
さらに参照するには、リンクに従ってください: http://msdn.microsoft.com/en-us/library/ff650591.aspx#_Step_7:_Impersonate