Reputation: 27394
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.
Upvotes: 3
Views: 3259
Reputation: 6297
I believe there is something in the operation context. Try this:
OperationContext oc = OperationContext.Current;
ServiceSecurityContext ssc = oc.ServiceSecurityContext;
string client = ssc.PrimaryIdentity.Name;
Upvotes: 1
Reputation: 34427
Not sure, but you may be looking for
var userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;
Upvotes: 9