2010-12-17 25 views
2

wcfサービスの簡単な「ユーザー名」/「パスワード」認証を実装しようとしています。しかし、それだけで動作していません。エラー/例外はありません。ここ は、Web構成コードです:WCFカスタム認証が機能しない

<?xml version="1.0"?> 
    <configuration>  
     <system.web> 
      <compilation debug="true" targetFramework="4.0"/> 
      <customErrors mode="Off"/> 
     </system.web> 
     <system.serviceModel> 
     <services> 
     <service name="XYZService" 
       behaviorConfiguration="XYZBehavior">   
     <!-- use base address specified above, provide one endpoint --> 
     <endpoint address="" 
        binding="basicHttpBinding" 
        bindingConfiguration="XYZBinding" 
        contract="IXYZService" /> 
     <!--<endpoint address="mex" 
        binding="mexHttpBinding" 
        contract="IMetadataExchange" />--> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="XYZBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Basic" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
     <behaviors> 
       <serviceBehaviors> 
        <behavior> 
         <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
         <serviceMetadata httpGetEnabled="true"/> 
         <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
         <serviceDebug includeExceptionDetailInFaults="true"/> 
         <serviceCredentials> 
          <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="XYZBinding.LicensingServer.CCustomValidatorClass, XYZBinding.LicensingServer"/> 
         </serviceCredentials> 
        </behavior> 
       </serviceBehaviors> 
      </behaviors> 
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
     </system.serviceModel> 
     <system.webServer> 
      <modules runAllManagedModulesForAllRequests="true"/> 
     </system.webServer> 
    </configuration> 

検証コード:

public class CCustomValidatorClass : UserNamePasswordValidator 
    { 
     public override void Validate(string userName, string password) 
     { 
      if(userName != "Test" || password != "1234567") 
      { 
       throw new FaultException("The provided credentials are invalid."); 
      } 
     } 
    } 

エラーまたは例外なしはありません。私はサービスを呼び出して、資格情報なしで実行することができます。ローカルデバッグでは、validateメソッドは決してヒットしません。

私は何が欠落しているのか分かりません。

+0

私はWCFの専門家ではありませんが、これらのシナリオの最初の質問は常に「この設定が使用されていますか?」です。これを確認するには、アプリを壊すような設定を変更してください。アプリがまだ動作している場合は別の設定を使用しています: – TToni

+0

'customUserNamePasswordValidatorType'を更新したばかりで、wcfテストクライアントがエラーを投げました。オリジナルに戻しました。 WCFテストクライアントは円滑に動作します。 –

+1

セクションで、あなたの設定に重要で興味深い部分を表示しているわけではありません。実際にこれらのバインド構成とセキュリティ設定を使用するサービスもありますか?これまでに投稿した内容から、それはそうではありません.... –

答えて

関連する問題