如果我不编写客户端,如何捕获 WCF 服务的用户名和密码?
我正在编写一个需要用户名和密码身份验证的 WCF 服务,但是,我不负责编写客户端来访问该服务,因此我不确定如何访问用户名和密码。举个例子,在测试时,我创建了服务,然后创建了一个测试应用程序,它将为我实例化一个客户端,然后我将设置用户名和密码,如下所示:
WcfClient client = new WcfClient();
client.ClientCredentials.UserName.UserName = "test";
client.ClientCredentials.UserName.Password = "test";
client.Open();
我是否必须以某些方式捕获客户端的用户名和密码标题,如果是的话我该怎么做?也许 WCF 已经为此做好了准备,但我还不明白。如果需要更多说明,我很乐意编辑该帖子。
I am writing a WCF Service that will require a username and password authentication, however, I am not responsible for writing the clients to access the service, so I am not sure how I can access the username and password. To give an example, when testing, I created the service and then I created a test application that would instantiate a client for me and then I would set the username and password like so:
WcfClient client = new WcfClient();
client.ClientCredentials.UserName.UserName = "test";
client.ClientCredentials.UserName.Password = "test";
client.Open();
Do I have to capture the client's username and password in some header, if so how would I go about doing this? Maybe WCF has something in place for this, but I don't understand it yet. If more clarification is needed, I will be glad to edit the post.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 ASP.NET 成员资格提供程序的内置 WCF 支持< /a> 或使用您自己的自定义用户名验证器。 ASP. NET 成员资格提供程序方法是一个更完整的解决方案,因为它还有一个 admin维护用户名和密码的能力。
You can either go with the built-in WCF support for the ASP.NET membership provider or with rolling your own custom username validator. The ASP.NET membership provider approach is a more complete solution because it also has an admin capability to maintain the user names and passwords.