【问题标题】:Restrict the client connection in WCF service限制 WCF 服务中的客户端连接
【发布时间】:2017-10-29 14:29:18
【问题描述】:

我创建了一个 WCF 服务并将其托管在控制台应用程序中。我有 2 个客户端应用程序将与该 WCF 服务通信,现在我想限制 3 个客户端连接到该 WCF 服务。

有没有办法拒绝第三个客户端的服务器端连接? 或者服务器有什么方法可以在建立连接之前验证连接 客户?

服务器端代码

Uri httpBaseAddress = new Uri("net.pipe://localhost/ServiceHost/ServiceHost"); 
studentServiceHost.AddServiceEndpoint(typeof(StudentService.IStudentService), binding, httpBaseAddress); 
studentServiceHost.Open()

【问题讨论】:

  • 你客户的IP是静态的吗?
  • 是的,url是静态的,服务和客户端都在同一台机器上运行
  • 同一台机器,然后按照 Shiraz bhaiji 的建议,您必须使用 Soap 标头。因此,您可以传递一个密钥并根据值区分客户端。
  • 我是这项技术的新手,所以粘贴示例代码/应用程序会很有帮助

标签: wcf wcf-security


【解决方案1】:

如果您想同时停止 3 个客户端从 Connection 到服务,您可以使用绑定的 maxConnections 属性,将其设置为 2。

如果您只希望特定客户访问您的服务。然后需要设置认证,见:WCF self hosting require authentication

【讨论】:

  • 是的,实际上,微软攻击面分析工具检测到我的namedpipe存在安全风险,并建议“ACL必须严格”,所以我想避免这种情况
猜你喜欢
  • 1970-01-01
  • 2011-09-10
  • 1970-01-01
  • 1970-01-01
  • 2010-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多