2010-12-19 26 views
1

WCFサービスWebConfig(部分)。WCFカスタム認証 - HTTPステータス401:無許可

<services> 
      <service name="Bricks99.LicensingServer.LicensingService" 
        behaviorConfiguration="Bricks99ServiceBehavior">   
      <!-- use base address specified above, provide one endpoint --> 
      <endpoint address="" 
         binding="basicHttpBinding" 
         bindingConfiguration="Bricks99Binding" 
         contract="Bricks99.LicensingServer.ILicensingService" /> 
      <!--<endpoint address="mex" 
         binding="mexHttpBinding" 
         contract="IMetadataExchange" />--> 
      </service> 
    </services> 
    <basicHttpBinding> 
      <binding name="Bricks99Binding"> 
       <security mode="TransportCredentialOnly"> 
       <transport clientCredentialType="Basic" /> 
       </security> 
      </binding> 
    </basicHttpBinding> 
<serviceCredentials> 
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Bricks99.LicensingServer.CCustomValidatorClass, Bricks99.LicensingServer"/> 
</serviceCredentials> 

Clientは、ASP.NET 2.0

LicensingService service = new LicensingService(); 
      //Authentication    
CredentialCache credCache = new CredentialCache(); 
      credCache.Add(new Uri(service.Url), "Basic", new NetworkCredential("Test", "1234567")); 
service.Credentials = credCache; 
service.PreAuthenticate = true; 
service.UseDefaultCredentials = false; 
result = service.VerifyLicenseKey(licenseKey, string.Empty); 

ある結果は、要求がHTTPステータス401で失敗しましたいつもです:不正な。私はまた、フォルダの匿名アクセスをオフにしました。まだ動作していません。 資格情報を正しく設定する方法に関するアイデアはありますか?

EDITは:

public override void Validate(string userName, string password) 
     { 
      try 
      { 
       if(userName != "Test" || password != "1234567") 
       { 
        throw new FaultException("The provided credentials are invalid."); 
       } 
      } 
      catch(FaultException ex) 
      { 
       LicensingData.Operations.LogError(ex);     
      } 
     } 

がヒットしないばかりんオーバーライドされたメソッドのように思えます。

答えて

1

調査の時間がたっても、ホスティングプロバイダがデフォルトでの基本認証を許可していないことがわかりました。カスタム認証を機能させるには、IISで基本認証を有効にする必要があります。

関連する問題