簡體   English   中英

使用IIS和應用程序池進行WCF Windows身份驗證

[英]WCF windows authentication with IIS and Application Pool

我有一個使用自定義標識的應用程序池在IIS 6上運行的WCF服務器

現在,我在網上看了兩天,但找不到我的問題的確切答案。 我知道外面有很多類似的東西

在IIS6上,虛擬目錄已禁用匿名訪問並啟用了集成Windows身份驗證。 服務帳戶與計算機在同一域中。 我將其稱為svcE。 我將svcE添加到IIS_WPG組。

現在,第一個問題是,當我選擇帶有svcE的應用程序池以在虛擬目錄上工作時,將其稱為appDir,然后當我導航至appDir時,系統會提示我輸入憑據,但是如果我使用網絡服務帳戶,則不這樣做,並驗證我是否以我的身份登錄。

我想要做的是讓該服務在svE帳戶下運行,因為它可以訪問數據庫,而無需將該信息放入WebConfig文件中。

我有一個帶有配置文件的Web服務

<authentication mode="Windows"/>

<bindings>
        <basicHttpBinding>
            <binding name="default">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows"/>
                </security>                  
            </binding>
        </basicHttpBinding>
    </bindings>

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="default" contract="<removed>">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>   

使用該服務的Web配置具有

<basicHttpBinding>
            <!-- Create one Binding for all three services, save space-->
            <binding name="BasicHttpBinding_PricingService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" proxyCredentialType="Windows"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>

        </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="<address>.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PricingService"
            contract="<contract>" name="<name>" />

最后,我想達到的目標是

只有經過Windows身份驗證的人員才能調用該服務->然后,該服務將使用一個私人帳戶來與數據庫進行所有交互。

請注意,如果我跳過了第一部分並添加了匿名訪問權限,則它可以正常工作並稱為數據庫正常

感謝您的幫助

如果要以特定帳戶進行數據庫調用,則可以模擬該帳戶來進行通話:

using ( WindowsImpersonationContext contexts = (new WindowsIdentity("account").Impersonate()){ db.MakeCall(); }

如果仍然有人在這個問題上掙扎,那么您要做的就是在web.config上模擬您的服務帳戶:

<identity impersonate="true" userName="domain\svcname" password="password"/>

當用戶使用Windows身份驗證進行連接時,您的服務似乎正在冒充用戶。

使用匿名身份驗證時,沒有模擬,因此沒有問題。

當您使用Windows身份驗證和一個domian帳戶時,該帳戶未標記為可以模擬,這可能就是您獲得登錄名的原因,默認情況下,網絡服務具有該權限。

嘗試:

<authentication mode="Windows" impersonate="false"/>

我有同樣的問題。

我需要授予對c:\\ inetpub \\ wwwroot \\文件夾的訪問權限。

我授予“ DomainUsers”組讀取權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM