【问题标题】:Impersonate WCF service to run under a specific Domain Account(Hosted on IIS)模拟 WCF 服务以在特定域帐户下运行(托管在 IIS 上)
【发布时间】:2014-02-24 20:28:45
【问题描述】:

我希望在 IIS 服务器上托管的 WCF 服务应模拟特定的域帐户。 如果是普通网站,我使用以下代码模拟特定域帐户:

<system.web>
  <!-- ASP.NET runs as the specified user -->
  <identity impersonate="true"
            userName="DOMAIN\user"
            password="password" />
</system.web>

我需要一些类似的方法,我可以在我的 WCF 服务 web.config 文件中使用它来模拟特定的域帐户,以便所有 WCF 的操作都将在此帐户下运行。

【问题讨论】:

  • 您可以在单独的应用程序池中运行该服务,并让该应用程序池在域服务帐户下运行。这可能会让你到达你想去的地方。
  • 嗨蒂姆,感谢您花时间查看我的问题。根据 IT 指南,我需要遵循 IIS 中其他网站存在的保存方式。我们无法为应用池定义特定的域帐户。
  • 在配置文件中似乎没有直接的方法来执行此操作(基于快速搜索),但 MSDN 上有许多选项 - Delegation and Impersonation with WCF - 这个可能会有所帮助(尽管使用应用程序池并在域帐户下运行它会更容易、更安全,IMO)。

标签: wcf impersonation


【解决方案1】:

我不知道这是否是一个好方法,但是我使用以下步骤来解决我的问题。

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="True">
    </serviceHostingEnvironment>
    <services>
      <service name="Service" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="basicHttpBinding" contract="IService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          ........some othere setting
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

在system.web下添加我我使用如下代码

<system.web>
   <authorization>
        <allow users="?"/>
      </authorization>
  <identity impersonate="true" userName="DOMAIN\user" password="password" />
</system.web> 

关于我添加的 Service.vb 类

<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
Public Class Service Implements IService

【讨论】:

    猜你喜欢
    • 2010-10-01
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-06
    • 2016-01-25
    • 1970-01-01
    相关资源
    最近更新 更多