开发者

WCF UserNamePasswordValidator - Access credentials after validation

I am using the UserNamePasswordValidator class as part of the UserName security with WCF. This all works great and the Validate function of the class gets called and works properly.

How then can I find out what UserName was used in my service functions?

For example say if a client connects and requests a list of logs using something like

ILi开发者_Python百科st<Log> Logs() { ... }

How can that function know which UserName was used on that request?

What I want to do is log what UserName calls what function within the service.


Not sure, but you may be looking for

var userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;


I believe there is something in the operation context. Try this:

OperationContext oc = OperationContext.Current;
ServiceSecurityContext ssc = oc.ServiceSecurityContext;
string client = ssc.PrimaryIdentity.Name;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜