积极答复者
WCF Data Service应该使用什么身份验证方式

问题
-
我创建了一个wcf data service服务,之前一直用基本身份验证方式,但是我发现它要求输入的用户名密码却是服务器端的用户的用户名密码,因为在IIS上我配置的应用程序池是使用虚拟帐户IIS AppPool\Name,NTFS也给的是虚拟帐户的权限。所以我没有办法得到这个虚拟帐户的密码。所以我现在使用的是匿名身份验证,然后再配置中加入Modules来自己验证,然后再使用Https和证书的方式加密传输层,不知道这样是否可行?
<system.webServer> <modules> <add name="BasicAuthenticationModule1" type="wcfdataservice.BasicAuthenticationModule"/> </modules> </system.webServer>
我不清楚具体应该使用什么样的身份验证?
答案
-
你使用Module实现,要求WCF兼容ASp.net方式。这种也是可行。
其实WCF DataService支持WCF自己的验证方式。比如
下面的例子
NorthwindEntities1 entity = newNorthwindEntities1
15.
(newUri(
"http://localhost:7890/wcfdataservice1.svc/"
));
16.
entity.Credentials = System.Net.CredentialCache.DefaultCredentials;
17.
entity.Credentials = newSystem.Net.NetworkCredential(
"UserName"
,
"Password"
,
"Domian"
); 你可以参考一下文章
http://openlightgroup.net/Blog/tabid/58/EntryId/100/Simple-Example-To-Secure-WCF-Data-Service-OData-Methods.aspx
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/
- 已标记为答案 Peter pi - MSFTModerator 2011年9月22日 8:33
全部回复
-
你使用Module实现,要求WCF兼容ASp.net方式。这种也是可行。
其实WCF DataService支持WCF自己的验证方式。比如
下面的例子
NorthwindEntities1 entity = newNorthwindEntities1
15.
(newUri(
"http://localhost:7890/wcfdataservice1.svc/"
));
16.
entity.Credentials = System.Net.CredentialCache.DefaultCredentials;
17.
entity.Credentials = newSystem.Net.NetworkCredential(
"UserName"
,
"Password"
,
"Domian"
); 你可以参考一下文章
http://openlightgroup.net/Blog/tabid/58/EntryId/100/Simple-Example-To-Secure-WCF-Data-Service-OData-Methods.aspx
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/
- 已标记为答案 Peter pi - MSFTModerator 2011年9月22日 8:33