开发者

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

开发者 https://www.devze.com 2023-03-05 00:16 出处:网络
I have just created my first WCF service. Now I would like to do the following: Add my custom authentication mechanism, e.g., querying a database\'s user table.

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

精彩评论

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

关注公众号