简体   繁体   English

WCF使用用户名身份验证和邮件安全性

[英]WCF Using UserName Authentication with Message Security

I am developing an ASP.NET application which will be calling (extensively) WCF services. 我正在开发一个ASP.NET应用程序,该应用程序将(广泛地)调用WCF服务。 Now, I am obviously having some kind of mental melt down as I can't for the life of me get this wrapped around my head correctly. 现在,我显然有些精神崩溃,因为我无法终生正确地将其包裹在头上。

I am using ws2007HttpBinding with Message security and ClientCredentialType of UserName. 我正在使用具有邮件安全性和UserName的ClientCredentialType的ws2007HttpBinding。 The WCF is using the ASP.NET Membership provider to validate the user's credentials. WCF使用ASP.NET成员资格提供程序来验证用户的凭据。

This all works fine but I obviously need to include the user details in ever call: 一切正常,但我显然需要在每次通话中包括用户详细信息:

var service = new MyService.MyServiceClient();
service.ClientCredentials.UserName.UserName = "my_username";
service.ClientCredentials.UserNane.Password = "mypassword";

.... etc ...

service.Close();

Now, this is easy from the login page as the user has just given us their username and password. 现在,在登录页面上这很容易,因为用户刚刚给了我们他们的用户名和密码。 I am not comfortable with storing the password for use later on down the road when we need to call another service with the users credentials. 当我们需要使用用户凭据调用另一个服务时,我不愿意存储密码以备后用。

Am I missing something obvious? 我是否缺少明显的东西? I have read about tokens etc but I not entirely sure how to go about implementing that kind of thing. 我已经阅读了有关令牌等的内容,但我不完全确定如何去实现这种东西。 I have spent all day searching and reading and I am still unsure, so any help you can give will be greatly appreciated! 我花了一整天的时间进行搜索和阅读,但仍不确定,因此,您能提供的任何帮助将不胜感激!

The easiest way might be really to store the password in a custom indentity. 最简单的方法可能实际上是将密码存储在自定义身份中。 In an ideal world you would use eg Kerberos and delegation. 在理想的情况下,您将使用例如Kerberos和委托。 Look for further information about impersonation and delegation. 查找有关模拟和委派的更多信息。

Quite a good article: 相当不错的文章:

http://msdn.microsoft.com/en-us/library/ms998358.aspx#paght000025_usingimpersonation http://msdn.microsoft.com/zh-CN/library/ms998358.aspx#paght000025_using模仿人

But all this stuff does not work with a membership provider. 但是,所有这些内容不适用于会员提供者。 You need Windows authentication with an Active Directory. 您需要使用Active Directory进行Windows身份验证。

This topic is not a too easy one... just as an idea: do you really need to authenticate at the web service with the credentials of the interactivly logged on user? 这个主题不是一个容易的话题……只是一个想法:您真的需要使用交互登录用户的凭据在Web服务上进行身份验证吗?

HTH a bit, Alex 有点HTH,Alex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM