开发者

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 nee开发者_运维问答d.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜