【问题标题】:WCF Services Authorisation to a service function without membership providerWCF 服务对没有成员资格提供程序的服务功能的授权
【发布时间】: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


    【解决方案1】:

    要连接自定义主体权限,您可以使用自定义 IAuthorizationPolicy 实现。示例见http://leastprivilege.com/2007/08/08/custom-principals-and-wcf/

    【讨论】:

    • 我们可以在 WCF 服务中同时使用基于服务凭据的身份验证和授权策略吗?
    • 是的。有关示例,请参见 neovolve.com/post/2008/04/07/…
    猜你喜欢
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    • 2011-02-06
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多