0
私はコンソールアプリケーションの中でホストされている簡単なWebサービスを持っています。 1つの問題があり、認証が正しく機能しません。なぜUserNamePasswordValidator.Validateが呼び出されないのですか?
私のapp.configは以下の通りです:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Mg">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="TSOWS.UserValidator,TSOWS" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
<services >
<service name="TSOWS.TSOWS" behaviorConfiguration="Mg" >
<endpoint address="/MyAddress" binding="wsHttpBinding" contract="TSOWS.ITSOWS" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<host>
<baseAddresses >
<add baseAddress="http://10.120.170.181:8181/TSOWS.svc" />
</baseAddresses>
</host>
</service >
</services>
</system.serviceModel>
と私のバリデータは次のとおりです。
public class UserValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "TSOWSUser" && password == "password"))
{
throw new SecurityTokenException("Unknown Username or Password");
}
}
}
UserValidator.Validateが呼び出されることはありませんし、Webサービスが開いており、必要にはありません
ユーザー名またはパスワードを入力します。
これはなぜ起こっているのですか?
認証を使用するにはサーバー証明書が必要ですか?