2012-07-09 64 views
1

我在IIS7安裝了啓用Windows身份驗證的網站。WCF REST安全模擬

我在我的服務中有3種方法,2種方法需要Windows身份驗證,1種方法不需要。不使用

[OperationBehavior(Impersonation = ImpersonationOption.Allowed)] 

另2使用

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 

我的web.config中的一個是這樣的:

<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"> 
    <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
</modules> 
<security> 
    <authentication> 
    <anonymousAuthentication enabled="true"/> 
    <windowsAuthentication enabled="true" /> 
    </authentication> 
</security> 


</system.webServer> 
    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      <serviceAuthorization impersonateCallerForAllOperations="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" maxBufferPoolSize="2147483647" 
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </standardEndpoint> 
     </webHttpEndpoint> 
    </standardEndpoints> 
    </system.serviceModel> 

當我運行嘗試執行的方法設置爲允許,我不會傳遞任何憑據,它會失敗並出現未經授權的錯誤。我錯過了什麼?

回答