简体   繁体   English

WCF禁用匿名身份验证

[英]WCF disable anonymous authentication

I actually have a little problem with a WCF. 我实际上对WCF有一点问题。 Everything is ok except the fact that when I disable Aninymous Authentication on IIS, there are no results returned. 一切正常,除了以下事实:当我在IIS上禁用Aninymous Authentication时,没有返回结果。 I didn't wrote this code, it's from a co-worker who left the company. 我没有编写此代码,它是由离开公司的一位同事提供的。 Here's the Web.Config form the WCF: 这是WCF的Web.Config:

    <?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
      <source name="myUserTraceSource"
              switchValue="Information, ActivityTracing">
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml"
           type="System.Diagnostics.XmlWriterTraceListener"
           initializeData="Error.svclog"/>
    </sharedListeners>
  </system.diagnostics>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <uri>
    <schemeSettings>
      <clear/>
      <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
      <add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
    </schemeSettings>
  </uri>
  <system.net>
    <settings>
      <httpListener unescapeRequestUrl="false"/>
    </settings>
  </system.net>
  <system.web>
    <httpRuntime maxQueryStringLength="2048" maxUrlLength="4000" requestPathInvalidCharacters="" requestValidationMode="2.0" targetFramework="4.5"/>
    <pages validateRequest="false"/>
    <compilation targetFramework="4.5" debug="true"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="RestBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="MetadataBehavior">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="https" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MetadataBehavior" name="MyWCF.MyService">
        <!-- Configuration HTTPS-->

        <!--<endpoint address="SoapSecure" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyWCF.IMyService"/>
        <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="https" name="REST" contract="MyWCF.IMyService"/>-->

        <!-- Configuration HTTP-->
        <endpoint address="Soap" binding="basicHttpBinding" bindingConfiguration="" contract="MyWCF.IMyService"/>
        <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="MyWCF.IMyService"/>

      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true"/>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        Pour parcourir le répertoire racine de l'application Web lors du débogage, définissez la valeur ci-dessous sur true.
        Définissez-la sur false avant le déploiement pour ne pas divulguer d'informations du dossier de l'application Web.
      -->
    <directoryBrowse enabled="true"/>
    <!-- MK 27/10/2014: Access control same origin hotfix-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*"/>
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

Right now, the resolution of this problem is critical for the client, so I highly appreciate suggestions and any kind of help. 目前,解决此问题对客户至关重要,因此,我非常感谢您的建议和任何帮助。

Thank you for your time 感谢您的时间

If you are disabling Anonymous Authentication you must also set the clientCredentialType as None 如果要禁用匿名身份验证,则还必须将clientCredentialType设置为None

    <security mode="Transport">
        <transport clientCredentialType="None" />
    </security>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF安全-Https和匿名身份验证 - WCF Security - Https and Anonymous Authentication WCF Web服务匿名身份验证 - WCF Web service Anonymous Authentication 通过禁用匿名身份验证,WCF REST服务出现问题 - Issue with WCF REST Service by disabling Anonymous Authentication WCF-TransportWithMessageCredential使用客户端身份验证方案“匿名”对HTTP请求进行未授权 - WCF-TransportWithMessageCredential The HTTP request is unauthorized with client authentication scheme 'Anonymous' 从IIS到WCF服务的IIS中的匿名身份验证在Windows身份验证的网站中进行路由 - Anonymous Authentication in IIS to WCF service routes in an otherwise windows authenicated website 具有WsHttpBinding和Windows身份验证的WCF服务因匿名访问错误而失败 - WCF service with WsHttpBinding & windows authentication failing with anonymous access error WCF不适用于IIS中禁用的匿名身份验证选项 - WCF doesn't work with disabled anonymous authentication option in IIS WCF自托管:匿名身份验证方案禁止使用HTTP请求 - WCF self-hosted: http request forbidden for authentication scheme anonymous 具有匿名身份验证的IIS站点和具有基本身份验证的WCF服务可以在同一域中吗? - IIS Site with Anonymous authentication and WCF service in the same domain with Basic authentication is it possible? 添加WCF服务引用时,HTTP请求被禁止,客户端身份验证方案“匿名”错误 - The HTTP request was forbidden with client authentication scheme 'Anonymous' error, when adding WCF service reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM