Saturday, June 20, 2009 - 文章

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>

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

Posted 20 June 2009 03:23 AMJeffrey | 1 comment(s)
Filed under:

搜尋

Go

<June 2009>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
 
RSS
【工商服務】
最新回應

Tags 分類檢視
關於作者

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

文章典藏
其他功能

這個部落格


BlogLook Score and Rank

Syndication