我试图用https和用户名&密码来保护WCF服务。我正在使用TransportWithMessageCredentials安全模式和wsHttpBinding。 现在我在与定制UserNamePasswordValidator麻烦,当我比较喜欢这个WCF服务与自定义用户名密码验证问题
if (userName == "user" && password == "pass")
return;
一切硬编码值工作正常,但是当我试图从数据库中我收到错误消息
值从其他 方收到一个不安全或不正确安全的 错误。见内的FaultException 的故障代码和详细
这里是我的web.config部分,
<bindings>
<wsHttpBinding>
<binding name="TestAuthConf" maxReceivedMessageSize="65536">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
<readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" maxStringContentLength="65536"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TestAuthWCFService.TestAuthBehavior" name="TestAuthLibrary.App_Code.TestAuth">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="TestAuthConf" contract="TestAuthLibrary.App_Code.ITestAuth">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="TestAuthLibrary.App_Code.ITestAuth"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestAuthWCFService.TestAuthBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="App_Code.CustomUserNameValidator, App_Code.CustomUserNameValidator"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
我使用IIS7,自我生成数字证书,我设置了SSL接受客户端证书...
任何帮助将appriciated ...
可能在您的代码访问数据库中存在异常。例如,可能没有足够的权限来从数据库读取数据。什么是内部例外?打开服务上的WCF跟踪:http://msdn.microsoft.com/en-us/library/ms733025.aspx – 2011-03-23 14:15:49
内部例外:“验证邮件的安全性时发生错误”,我没有检查权限,一切正常,WCF跟踪打开了,我测试了访问数据库的方法,没有问题... – 2011-03-23 14:37:06