Null Reference
Null Reference

Reputation: 11340

Keeping the UserName of a client on WCF PerCall service

Each time a client calls my WCF service, I would like to log that request down into the database, which will include details such as the username of that client.

I'm currently using a custom authentication with my WCF service.

Is it possible to somehow get the username of the caller each time my WCF service is called, or do I have the pass the username with each call every time?

Upvotes: 1

Views: 409

Answers (1)

vibhu
vibhu

Reputation: 1695

To retrieve the user name of the caller, you can inherit from System.IdentityModel.Selectors.UserNamePasswordValidator and override Validate Method as you deem appropriate. As for per call instancing mode, WCF creates new instance of service for every call, so each of your call should be authenticated with right credentials. I think you can specify credentials once while opening the proxy and that proxy would present the credentials each time it requests an operation to the service (until proxy is closed and you create a new proxy all together). This link might be useful - http://www.codeproject.com/Articles/96028/WCF-Service-with-custom-username-password-authenti

Upvotes: 1

Related Questions