Reputation: 263
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>
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.
Upvotes: 0
Views: 2294
Reputation: 263
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>
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>
on Service.vb class I added
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
Public Class Service Implements IService
Upvotes: 1