2010-12-19 7 views
1

WCF 서비스 웹 구성 (부분).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> 

클라이언트는 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 실패 항상 입니다 : 무단. 또한 폴더의 익명 액세스를 해제했습니다. 아직도 작동하지 않습니다. 자격 증명을 올바르게 설정하는 방법에 대한 아이디어가 있으십니까?

편집 :

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);     
      } 
     } 

가 충돌하지 지 않습니다 오버라이드 (override) 된 메소드처럼 보인다.

답변

1

연구 시간 후 나는 호스팅 제공 업체가 기본 인증을 허용하지 않는다는 것을 알게되었습니다. 사용자 지정 인증을 사용하려면 IIS에서 기본 인증을 사용하도록 설정해야합니다.

관련 문제