.net 使用存储在IIS服务器注册表中的专用系统帐户在WCF中连接数据库

.net 使用存储在IIS服务器注册表中的专用系统帐户在WCF中连接数据库,.net,wcf,iis,dbconnection,.net,Wcf,Iis,Dbconnection,我有一个WCF服务项目,它连接到SQLServer2008来执行插入、更新、删除和选择等操作。在IIS上,我希望通过使用存储在服务器注册表中的专用系统帐户连接到sql server。我在我的wcfweb.config中使用以下代码从服务器的注册表获取userID和Passward <System.web> <identity impersonate="true" userName="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctop

我有一个WCF服务项目,它连接到SQLServer2008来执行插入、更新、删除和选择等操作。在IIS上,我希望通过使用存储在服务器注册表中的专用系统帐户连接到sql server。我在我的wcfweb.config中使用以下代码从服务器的注册表获取userID和Passward

<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>
我获取用户域\服务器名的登录失败错误消息

IIS服务器上的身份验证级别为匿名身份验证

任何帮助都将不胜感激。
谢谢,瑜珈修行者,我不知道这是否是一个好方法,但是我使用了以下步骤来解决我的问题

<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下添加I我使用以下代码

<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> 
在Service.vb上添加了I类

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