简体   繁体   English

使用IIS和应用程序池进行WCF Windows身份验证

[英]WCF windows authentication with IIS and Application Pool

I have a WCF Server running on IIS 6 using a application pool with a custom identity 我有一个使用自定义标识的应用程序池在IIS 6上运行的WCF服务器

right now the I looked on the web for two days and I can't find the exact answer to my problem. 现在,我在网上看了两天,但找不到我的问题的确切答案。 I know there are a lot of similar ones outer there 我知道外面有很多类似的东西

On IIS6 the virtual directory has anonymous access disable and Integrated Windows authentication enabled. 在IIS6上,虚拟目录已禁用匿名访问并启用了集成Windows身份验证。 The service account is on the same domain as the machine. 服务帐户与计算机在同一域中。 I will call it svcE. 我将其称为svcE。 I added svcE to the IIS_WPG group. 我将svcE添加到IIS_WPG组。

Now, first issue is when I select that application pool with svcE to work on Virtual Directory, call it appDir, then when I navigate to appDir I get prompted for credentials but if I use the network service account I do not and verify that I am logged in as me. 现在,第一个问题是,当我选择带有svcE的应用程序池以在虚拟目录上工作时,将其称为appDir,然后当我导航至appDir时,系统会提示我输入凭据,但是如果我使用网络服务帐户,则不这样做,并验证我是否以我的身份登录。

What I want to do is have the service run under the account svE because it has access to the database, without putting that info in the WebConfig file. 我想要做的是让该服务在svE帐户下运行,因为它可以访问数据库,而无需将该信息放入WebConfig文件中。

I have a web service with the config file 我有一个带有配置文件的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>   

The Web config using the service has 使用该服务的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>" />

Ultimatly what I am trying to achieve is 最后,我想达到的目标是

Only Windows Authenticated people can call the service --> Then the service uses a serivce account to have all interaction with the database. 只有经过Windows身份验证的人员才能调用该服务->然后,该服务将使用一个私人帐户来与数据库进行所有交互。

Note that if I skip the first part and add annon access then it works and called the database fine 请注意,如果我跳过了第一部分并添加了匿名访问权限,则它可以正常工作并称为数据库正常

Thank you for the help 感谢您的帮助

如果要以特定帐户进行数据库调用,则可以模拟该帐户来进行通话:

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

如果仍然有人在这个问题上挣扎,那么您要做的就是在web.config上模拟您的服务帐户:

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

It appears that your service is impersonating the user when the user connects with windows authentication. 当用户使用Windows身份验证进行连接时,您的服务似乎正在冒充用户。

When you use annonymous authentication, there is no impersonation therefore no problem. 使用匿名身份验证时,没有模拟,因此没有问题。

When you use windows authentication and a domian account, that account is not marked as it can impersonate maybe that is why you get the login, network service has that right by default. 当您使用Windows身份验证和一个domian帐户时,该帐户未标记为可以模拟,这可能就是您获得登录名的原因,默认情况下,网络服务具有该权限。

Try: 尝试:

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

I had the same problem. 我有同样的问题。

I needed to give access to the c:\\inetpub\\wwwroot\\ folder. 我需要授予对c:\\ inetpub \\ wwwroot \\文件夹的访问权限。

I gave the 'DomainUsers' group read permission. 我授予“ DomainUsers”组读取权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM