Question

I have WCF Service project which connect to the SQL server 2008 to do operation like Insert, Update, Delete and select. On IIS I want the connection to sql server is made by using dedicated system account which is stored in server's registry. I am using following code in my WCF web.config to get userID and Passward from server's registry

<System.web>
<identity impersonate="true"      userName="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,userName" password="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,password" />
</system.web>

I am getting login failed for User "Domain\ServerName" error message

Authentication level on IIS server is Anonymous Authentication

Any help would be appreciated. Thanks, Yogi

Was it helpful?

Solution

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="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,userName" password="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,password" />
</system.web> 

on Service.vb class I added

<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
Public Class Service Implements IService
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top