[英]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.