【问题标题】:How to implement a custom authentication mechanism for a WCF Web Service如何为 WCF Web 服务实现自定义身份验证机制
【发布时间】:2011-05-11 18:15:14
【问题描述】:

我刚刚创建了我的第一个 WCF 服务。现在我想做以下事情:

  1. 添加我的自定义身份验证机制,例如,查询数据库的用户表。

  2. 使我的服务操作的结果依赖于已登录的用户。

我该怎么做?

注意:我已经尝试过使用谷歌搜索,甚至使用“site:stackoverflow.com”和“site:codeproject.com”等网站过滤器,但找不到我需要的内容。

【问题讨论】:

    标签: .net wcf authentication custom-authentication


    【解决方案1】:

    您好,

    根据项目的规模,以下链接中列出的一些解决方案可能有点过头了,不过,请随意看看。

    WCF Security Practices

    【讨论】:

      【解决方案2】:

      创建自定义 UserNamePasswordValidator 并覆盖 Validate 方法。

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

      在您的服务实现中,您将可以访问“OperationContext.Current.ServiceSecurityContext.PrimaryIdentity”,这是经过身份验证的用户。

      【讨论】:

      • 另外,请确保选中“IsAuthenticated”以确保用户已通过身份验证。
      猜你喜欢
      • 2019-12-14
      • 2011-08-26
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多