customUserNamePasswordValidatorType이 있는데 IServiceBehavior ApplyDispatchBehavior() 구현의 코드에서 서비스 자격 증명을 설정하려고합니다.WCF customUserNamePasswordValidatorType
은 발리는 결코 실행되지 않습니다 나는이 같은 코드에 설정하면 문제가된다
serviceHostBase.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator =
new BigIPUsernamePasswordValidator() ;
serviceHostBase.Credentials.UserNameAuthentication.UserNamePasswordValidationMode =
UserNamePasswordValidationMode.Custom;
내가 설정에서 설정하면 다음이 수행합니다
이<serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" $customUserNamePasswordValidatorType="Quad.WCF.Security.BigIPUsernamePasswordValidator, Quad.WCF" /> </serviceCredentials>
이 동작을 설정 서비스 클래스의 속성으로 사용하고 중단 점을 설정하면 위의 코드가 실행되는 것을 볼 수 있습니다.
구성에서 모든 것이 코드로 설정 될 수 있어야한다는 것을 이해합니다. 그러나 IServiceBehavior ApplyDispatchBehavior() 구현에서이를 설정할 때는 작동하지 않습니다.
이것이 작동해야하는지 아니면 코드를 통해 다르게 수행해야하는지 어떻게 생각하세요?
public class MyCustomUserNameValidator: UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
// Example Only
return;
}
}
당신은 어떤을받을 수 있나요
ServiceHost customServiceHost = new ServiceHost(type);
customServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
customServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new MyCustomUserNameValidator();
customServiceHost.AddServiceEndpoint(typeof(IServiceContract), customBinding, "https://localhost:443");
customServiceHost.Open();
내 사용자 정의 유효성 검사기는 것만 큼 간단합니다 (단지,이 같은 일을 사용하지 않는 예!) :