isekaijin
isekaijin

Reputation: 19742

How to implement a custom authentication mechanism for a WCF Web Service

I have just created my first WCF service. Now I would like to do the following:

  1. Add my custom authentication mechanism, e.g., querying a database's user table.

  2. Make the results of my service's operations dependent on the user that has logged in.

How do I do that?

NOTE: I have already tried googling, even using site filters such as "site:stackoverflow.com" and "site:codeproject.com", but couldn't find what I need.

Upvotes: 0

Views: 1007

Answers (2)

groover
groover

Reputation: 79

Create a custom UserNamePasswordValidator and override the Validate method.

http://msdn.microsoft.com/en-us/library/aa702565.aspx

Inside your service implementation you'll have access to "OperationContext.Current.ServiceSecurityContext.PrimaryIdentity" which is the user that was authenticated.

Upvotes: 0

Ross Bush
Ross Bush

Reputation: 15175

Greetings,

Depending on the size of the project, some of the solutions outlined in the link below may be overkill, however, feel free to take a look.

WCF Security Practices

Upvotes: 2

Related Questions