如何保存在WCF用户对象 [英] How to save user object in WCF

查看:97
本文介绍了如何保存在WCF用户对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用自定义UserNamePasswordValidator的服务,并需要保存验证用户对象能够在后面的服务进行检索。我怎样才能做到这一点?或者我如何可以访问用户的凭据后来在服务?

I have a service that uses a custom "UserNamePasswordValidator" and need to save the validated user object to be able to retrieve it later in the service. How can I do this? Or how can I access the credentials of the user later in the service?

/尤

推荐答案

简短的回答是最正确的选择是创建一个的IPrincipal 实例代表经过身份验证的用户,并把它放在 Thread.CurrentPrincipal中

The short answer is that the most correct option is to create an IPrincipal instance that represents the authenticated user and put it on Thread.CurrentPrincipal.

在服务以后在同一线程上运行的所有代码将能够访问通过在Thread.CurrentPrincipal中身份验证的用户。

All code running on the same thread later in the service will be able to access the authenticated user through Thread.CurrentPrincipal.

这是身份验证的用户在.NET(也因此在WCF)打交道的标准方法。

This is the standard way of dealing with authenticated users in .NET (and therefore also in WCF).

这篇关于如何保存在WCF用户对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆