Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF UserNamePasswordValidator - Access credentials after validation

Tags:

c#

wcf

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

IList<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.

like image 778
Chris Avatar asked Sep 01 '26 15:09

Chris


1 Answers

Not sure, but you may be looking for

var userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;
like image 74
max Avatar answered Sep 03 '26 05:09

max



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!