新手对wcf宿主IIS的安全验证问题
我刚刚开始学WCF对于安全验证有很大迷惑,找了很多资料都不是太懂,所以发帖问下问题很简单,首先说明下我的WCF是宿主起IIS的
public class Service1 : IService1
{
[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
public string GetData(string ClientIdentity)
{
return ("成功调用");
}
}
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string ClientIdentity);
// TODO: 在此添加您的服务操作
}
客户端
ServiceReference1.Service1Client data = new ServiceReference1.Service1Client();
NetworkCredential credential = data.ChannelFactory.Credentials.Windows.ClientCredential;
credential.UserName = "jbye";
credential.Password = "bao.123";
IService1 calculator = data.ChannelFactory.CreateChannel();
MessageBox.Show(calculator.GetData("123"));
我的windows用户的确是在Administrators用户组里面的,但是每次调用都说拒绝访问,是为什么呢,我服务端和客户端的Web.config配置都是默认的,是不是有添加什么东西进去呢,谁知道怎样做,我是新手,所以很多地方不懂 --------------------编程问答-------------------- 如果你使用Windows 安全认证,那么还需要添加服务端证书才行。 --------------------编程问答--------------------
不对阿,我看网上源码没有用到证书,不过源码宿主不是IIS,但是代码能运行,也能WINDOWS账号验证的,买证书好贵哦,还有没有其他办法能限制用户访问我的WCF服务的权限呢 --------------------编程问答--------------------
还可以用 soapheader 的用户名密码验证
http://blog.csdn.net/fangxinggood/article/details/6144893 --------------------编程问答-------------------- 如果你都在一个域里,那么可以利用IIS Windows 认证。
看这个:http://www.cnblogs.com/xuanhun/archive/2011/06/29/2093119.html --------------------编程问答-------------------- 用的什么binding?
补充:.NET技术 , Web Services