customUserNamePasswordValidatorType不能使用正确的类型
本文关键字:类型 不能 customUserNamePasswordValidatorType | 更新日期: 2023-09-27 17:50:51
我正在配置消息级安全服务,我使用UserName身份验证作为clientCredentialType。就我所检查的而言,我已经给出了正确的类型,但在运行时给出了错误
Could not load file or assembly 'Service' or one of its dependencies.
The system cannot find the file specified.
这是网页。配置部分
<serviceCredentials>
<serviceCertificate findValue="MyWebSite"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Service.UserNamePassValidator,Service" />
</serviceCredentials>
这是我提到UsernamePassValidator类型的服务模型的一部分
这里是类
namespace Service
{
public class UserNamePassValidator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (!(userName == ConfigHelper.Get(ConfigHelper.CIMSBulkEmail, "ServiceUsername")
&& userName == ConfigHelper.Get(ConfigHelper.CIMSBulkEmail, "ServicePassword")))
{
throw new FaultException("Invalid credentials");
}
}
}
}
在配置中放置验证器类型的地方,第二部分是包含类的程序集的文件名。
Service.UserNamePassValidator, Service
这意味着你有一个名为Service.dll的dll。但事实并非如此。
所以它应该读:
Service.UserNamePassValidator, CertraxIMSWebSite
在我的例子中,我给带有服务凭据的行为指定了一个名称,但是在web中保留了没有名称和服务凭据要求的原始默认行为。配置文件。一旦我删除了默认行为(即使我已经根据服务契约通过名称指定了行为),一切都如预期的那样工作。我猜任何行为与空/无名称属性将适用于所有绑定?