Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF配置-主机上的自定义身份验证_Wcf_Web Config_Wcf Security - Fatal编程技术网

WCF配置-主机上的自定义身份验证

WCF配置-主机上的自定义身份验证,wcf,web-config,wcf-security,Wcf,Web Config,Wcf Security,我已经为此挣扎了几天了-我无法正确配置此WCF服务以使用自定义成员资格提供程序。当我启动测试客户端时,出现以下错误: 配置中指定的用户名/密码成员身份提供程序MidlandsCoop.MembersWcfService.Business.UserAuthentication无效。未找到在system.web/membership/providers下注册的此类提供程序 我一直在遵循这一点,但毫无结果。谁能告诉我哪里出了问题 这是我的web.config: 我的用户身份验证类如下所示: pub

我已经为此挣扎了几天了-我无法正确配置此WCF服务以使用自定义成员资格提供程序。当我启动测试客户端时,出现以下错误:

配置中指定的用户名/密码成员身份提供程序MidlandsCoop.MembersWcfService.Business.UserAuthentication无效。未找到在system.web/membership/providers下注册的此类提供程序

我一直在遵循这一点,但毫无结果。谁能告诉我哪里出了问题

这是我的web.config:


我的用户身份验证类如下所示:

public class UserAuthentication : UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {
        if (null == userName || null == password)
        {
            throw new ArgumentNullException();
        }

        var db = new PetaPoco.Database("MyDB");

        db.Fetch<dynamic>("SELECT Username, Password FROM MyTable WHERE Username=@0 AND Password =@1",
                             userName, password);
    }
}
公共类UserAuthentication:UserNamePasswordValidator
{
公共覆盖无效验证(字符串用户名、字符串密码)
{
如果(null==用户名| | null==密码)
{
抛出新ArgumentNullException();
}
var db=新的PetaPoco.数据库(“MyDB”);
db.Fetch(“从MyTable中选择用户名、密码,其中用户名=@0,密码=@1”,
用户名、密码);
}
}

如果您有任何建议,我们将不胜感激。

您提供的链接提到customUserNamePasswordValidatorType,以指定自定义身份验证类型,在您的案例中为UserAuthentication。我认为MembershipProviderName应该是从MembershipProvider类派生的类

尝试将membershipProviderName=“MidlandsCoop.MembersWcfService.Business.UserAuthentication”更改为customUserNamePasswordValidatorType=“MidlandsCoop.MembersWcfService.Business.UserAuthentication”。此链接提及元素的属性。请查看是否尚未加载。感谢您的响应-我现在收到此错误:无法从程序集“System.ServiceModel,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”加载类型“MidlandsCoop.MembersWcfService.Business.UserAuthentication”。已解决!只需要在类型名称之后添加名称空间。谢谢
public class UserAuthentication : UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {
        if (null == userName || null == password)
        {
            throw new ArgumentNullException();
        }

        var db = new PetaPoco.Database("MyDB");

        db.Fetch<dynamic>("SELECT Username, Password FROM MyTable WHERE Username=@0 AND Password =@1",
                             userName, password);
    }
}