gpt4 book ai didi

windows - 使用 IIS 和应用程序池的 WCF Windows 身份验证

转载 作者:可可西里 更新时间:2023-11-01 10:40:40 27 4
gpt4 key购买 nike

我有一个在 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>

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

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

谢谢你的帮助

最佳答案

如果您想以特定帐户的身份进行数据库调用,您可以在调用期间模拟该帐户:

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

关于windows - 使用 IIS 和应用程序池的 WCF Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1759329/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com