【问题标题】:WCF windows authentication with IIS and Application Pool使用 IIS 和应用程序池进行 WCF Windows 身份验证
【发布时间】:2010-12-18 01:49:46
【问题描述】:

我有一个在 IIS 6 上使用具有自定义标识的应用程序池运行的 WCF 服务器

现在我在网上看了两天,我找不到我的问题的确切答案。我知道外面有很多类似的

在 IIS6 上,虚拟目录禁用匿名访问并启用集成 Windows 身份验证。服务帐户与机器位于同一域中。我将其称为 svcE。我将 svcE 添加到 IIS_WPG 组。

现在,第一个问题是当我选择使用 svcE 的应用程序池在虚拟目录上工作时,将其命名为 appDir,然后当我导航到 appDir 时,我会收到提示输入凭据,但如果我使用网络服务帐户,我不会并验证我以我的身份登录。

我想做的是让服务在帐户 svE 下运行,因为它可以访问数据库,而无需将该信息放入 WebConfig 文件中。

我有一个带有配置文件的网络服务

<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>   

使用该服务的网络配置有

<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 Authenticated 的人才能调用服务 --> 然后服务使用服务帐户与数据库进行所有交互。

请注意,如果我跳过第一部分并添加匿名访问,那么它可以正常工作并调用数据库

感谢您的帮助

【问题讨论】:

    标签: windows wcf iis authentication application-pool


    【解决方案1】:

    如果有人还在为这个问题苦苦挣扎,您需要做的就是在 web.config 上模拟您的服务帐户:

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

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。

      我需要授予对 c:\inetpub\wwwroot\ 文件夹的访问权限。

      我授予“DomainUsers”组读取权限。

      【讨论】:

        【解决方案3】:

        如果您想以特定帐户进行 db 调用,您可以在调用范围内模拟该帐户:

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

        【讨论】:

          【解决方案4】:

          当用户使用 Windows 身份验证连接时,您的服务似乎在模拟用户。

          当您使用匿名身份验证时,没有假冒因此没有问题。

          当您使用windows身份验证和domian帐户时,该帐户不会被标记,因为它可以冒充可能这就是您获得登录名的原因,网络服务默认具有该权限。

          试试:

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

          【讨论】:

          • 这似乎不起作用。我也试过
          猜你喜欢
          • 2011-05-07
          • 1970-01-01
          • 2011-06-27
          • 2011-07-22
          • 1970-01-01
          • 1970-01-01
          • 2020-11-16
          • 1970-01-01
          • 2013-11-13
          相关资源
          最近更新 更多