Windows服务中的WCF安全性

Alp*_*nso 5 wcf windows-services wcf-security

我有一个WCF服务,可以作为控制台应用程序和Windows服务运行.我最近将控制台应用程序复制到具有以下安全设置的W2K3服务器:

<wsHttpBinding>
 <binding name="ServiceBinding_Security" transactionFlow="true" >
  <security mode="TransportWithMessageCredential" >
    <message clientCredentialType="UserName" />
  </security>           
 </binding>             
</wsHttpBinding> 

<serviceCredentials>
 <userNameAuthentication  userNamePasswordValidationMode="Custom" 
  customUserNamePasswordValidatorType="Common.CustomUserNameValidator, Common" />
</serviceCredentials>
Run Code Online (Sandbox Code Playgroud)

安全性正常,没有问题.我有完全相同的代码,但在Windows服务中运行,当我尝试从客户端调用任何方法时,我收到以下错误:

System.ServiceModel.Security.MessageSecurityException was unhandled
Message="An unsecured or incorrectly secured fault was received from 
         the other party. See the inner FaultException for the fault code and detail."
  Source="mscorlib"
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
       ......   
    (lots of stacktrace info - not very useful)

  InnerException: System.ServiceModel.FaultException
       Message="An error occurred when verifying security for the message."
Run Code Online (Sandbox Code Playgroud)

例外没有告诉我什么.我假设它与从Windows服务访问系统资源有关.我尝试在与控制台应用程序相同的帐户下运行它,但没有运气.有没有人有任何想法?

mar*_*c_s 0

您正在使用自定义用户/名称验证器 - Windows 服务是否有权访问该文件?

您使用什么帐户运行 NT 服务?

关闭所有安全功能后它还能工作吗?(只是去看看)

马克