TIPS-設定WCF使用Windows認證

原本測試OK的WCF,在取消IIS匿名存取,改用整合式驗證後出現以下錯誤訊息:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

爬了一下文,大致的心得是要在web.config改變安全設定。原本的設定是VS2008建立AJAX enabled WCF時自動產生的:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="WebApiAspNetAjaxBehavior">
                <enableWebScript/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <services>
        <service name="WebApi">
            <endpoint address="" behaviorConfiguration="WebApiAspNetAjaxBehavior" 
             binding="webHttpBinding" contract="WebApi"/>
        </service>
    </services>
</system.serviceModel>

要修改為:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="WebApiAspNetAjaxBehavior">
                <enableWebScript/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <services>
        <service name="WebApi">
            <endpoint address="" behaviorConfiguration="WebApiAspNetAjaxBehavior" 
              binding="webHttpBinding" contract="WebApi"
              bindingConfiguration="NTLMBinding"
              />
        </service>
    </services>
<bindings>
  <webHttpBinding>
    <binding name="NTLMBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
</system.serviceModel>

醬就可以柳~~~ (羞昂風)

Published 20 June 2009 03:23 AM 由 Jeffrey
Filed under:


意見

# Alfred said on 22 June, 2009 01:08 AM

哈哈,看到羞昂我忍不住大笑

在上班耶,嗯湯啊嗯湯~

你的看法呢?

(必要的) 
(必要的) 
(選擇性的)
(必要的) 

請輸入以上的數字:

【請注意】意見送出後可能需要幾分鐘才會出現在網頁上,請耐心等候。

搜尋

Go

<June 2009>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
 
RSS

Tags 分類檢視
關於作者

一個醉心技術又酷愛分享的Coding魔人,十年的IT職場生涯,寫過系統、管過專案, 也帶過團隊,最後還是無怨無悔地選擇了技術鑽研這條路,近年來則以做一個"有為的中年人"自許。

文章典藏
其他功能

這個部落格


BlogLook Score and Rank

Syndication