我有一个简单的 Web 服务,通过基于表单的身份验证来处理安全性。
WCFTestService.ServiceClient myService = new
WCFTestService.ServiceClient();
myService.ClientCredentials.UserName.UserName = "user";
myService.ClientCredentials.UserName.Password = "secret";
lblResult.Text = myService.GetData(1231);
myService.Close();
我正在通过网络应用程序访问它。所以我想做一次以上但为了安全/性能不必再做一次。我在想像下面这样的事情,但是当我使用 FormsAuthentication 时,这将不起作用...
//Obtain the authenticated user's Identity and impersonate the original caller
using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
{
WCFTestService.ServiceClient myService2 = new WCFTestService.ServiceClient();
lblResult.Text = "From Logged On Credentials"+myService2.GetData(1231);
myService2.Close();
}