使用 WCF 数据服务在服务器端按用户进行过滤
我正在尝试创建一个 WCF 数据服务服务,该服务允许将文档从服务器下载到运行 .NET 4.0 的客户端应用程序。
这些文档只能由拥有它们的用户下载。用户可以使用用户名和密码在服务器上进行身份验证。我找到了一种将用户凭据从客户端发送到服务器的方法 (DataServiceContext.Credentials
)。
我正在努力解决的问题是能够将服务返回的文档限制为用户拥有的子集。我可以很容易地检查用户名和密码是否有效,但我不确定应该如何使用它来过滤结果。
我的服务器上没有复杂的模型,只有文档和关联的用户帐户的列表。一些文档可以在多个用户之间共享。
我是否正在尝试执行 WCF 数据服务并非真正设计用途的操作?
I'm trying to create an WCF Data Services service which allows documents to be downloaded from a server, to client applications running .NET 4.0.
The documents should only be downloadable by the user which owns them. Users can be authenticated on the server with a username and password. And I've found a way of sending the user credentials from the client to the server (DataServiceContext.Credentials
).
The area that I'm struggling with is being able to restrict the documents returned by the service to just the subset owned by the user. I can check that the username and password is valid easily enough but I'm not sure how I should then use that to filter the results.
I don't have a complex model on the server, just a list of documents and associated user accounts. Some documents may be shared between a number of users.
Am I trying to do something which WCF Data Services isn't really designed for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经找到了一个很好的解决方案 - 查询拦截器:
如何to:拦截数据服务消息(WCF数据服务)
I think I've found a good solution - query interceptors:
How to: Intercept Data Service Messages (WCF Data Services)