我試圖用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