模拟WCF服务以在特定的域帐户下运行(托管在IIS上) [英] Impersonate WCF service to run under a specific Domain Account(Hosted on IIS)
问题描述
我希望IIS服务器上托管的WCF服务应模拟为特定的域帐户.如果是普通网站,我将使用以下代码模拟特定的域帐户:
I want my WCF service which is host on IIS server should impersonate to a specific Domain Account. In case of a normal website I am using below code to impersonate to specific domain account :
<system.web>
<!-- ASP.NET runs as the specified user -->
<identity impersonate="true"
userName="DOMAIN\user"
password="password" />
</system.web>
我需要类似的方法,可以在WCF服务的web.config文件中使用它来模拟特定的域帐户,以便所有WCF的操作都可以在该帐户下运行.
I need something similar approach which I can use in my WCF service web.config file to impersonate to a specific domain account so that all WCF's operation will run under this account.
推荐答案
我不知道这是否是一种好方法,但是我使用了以下步骤来解决问题.
I don't know whether is a good approach or not, however I used the following steps to resolve my issue.
<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下添加我,我使用以下代码
Add I under the system.web I use the following code
<system.web>
<authorization>
<allow users="?"/>
</authorization>
<identity impersonate="true" userName="DOMAIN\user" password="password" />
</system.web>
在我添加的Service.vb类上
on Service.vb class I added
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
Public Class Service Implements IService
这篇关于模拟WCF服务以在特定的域帐户下运行(托管在IIS上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!