0

我正在尝试编写将通过 Active Directory 服务进行搜索的 WCF 服务。我想将此服务设置为使用我的固定凭据,这样我的密码就不会过期。

这就是我的web.config样子:

 <?xml version="1.0"?>
 <configuration>
   <system.web>
     <compilation debug="true" targetFramework="4.0" />
     <authorization>
       <allow users="?"/>
     </authorization>
     <authentication mode="Windows"/>
     <identity impersonate="true" userName="mylogin" password="mypass" />
   </system.web>
   <system.serviceModel>
     <services>
       <service name="Mochrie.MyService" behaviorConfiguration="asdf">
         <endpoint address="" binding="basicHttpBinding" bindingConfiguration="httpBinding" contract="Mochrie.IMyService" />
       </service>
     </services>


     <bindings>
       <basicHttpBinding>
         <binding name="httpBinding">
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Basic" />
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>


     <behaviors>
       <serviceBehaviors>
         <behavior name="asdf">
           <serviceMetadata httpGetEnabled="true"/>
           <serviceDebug includeExceptionDetailInFaults="false"/>
         </behavior>
       </serviceBehaviors>
     </behaviors>
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
   </system.serviceModel>
   <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
 </configuration>

不幸的是,我收到了众所周知的错误并在几天内一直在苦苦挣扎。尝试浏览时:http://localhost/Mochrie/MyService.svc?wsdl

The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'BasicHttpBinding' ('Basic'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the <serviceAuthenticationManager> element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.

有没有人有机会解决这个问题并正确设置 wcf 服务?

4

1 回答 1

0

尝试

<binding name="MyBinding">

  <security mode="TransportCredentialOnly">

    <transport clientCredentialType="Windows" />

  </security>

</binding>

或者

<binding name="MyBinding">

  <security mode="TransportCredentialOnly">

    <transport clientCredentialType="Ntlm" />

  </security>

</binding>

注意:您可以关闭模​​拟但改为更改 IIS AppPool(或 WinService 帐户)身份

于 2013-04-10T08:23:34.857 回答