【发布时间】:2013-03-12 16:09:01
【问题描述】:
我有一个使用 UserNamePasswordValidator 进行身份验证的 WCF 服务。我检查用户名和密码。如果没问题,那么我允许访问服务调用。
class CustomUserNameValidator : UserNamePasswordValidator
{
WebServiceDM entity = new WebServiceDM();
public override void Validate(string userName, string password)
{
string encrypted = CryptographyManager.EncryptSymmetric(password);
Kullanici _user = entity
.Kullanici
.FirstOrDefault(h => h.Username == userName && h.Password == encrypted);
if (_user == null || _user.Username == "")
{
//Invalid User ...
throw new Exception("Username and password failed");
}
}
}
现在我需要一个基于函数的授权,例如 PrincipalPermission。但在这种情况下,我没有任何会员提供者。
[ServiceContract]
public interface IEglenceServices
{
[OperationContract]
List<EGLENCEBEYAN> GetEglenceBeyan(int yil);
}
那么我可以为这种情况做些什么呢?
【问题讨论】:
标签: c# .net wcf windows-identity