开发者

WCF and windows authentication not working

I cant get my WCF serve to windows authenticate

If I allow anonymous everything works, no errors.

I'm running .Net 3.5 on windows 2008 r2 standard SP1 IIS 7.5, if it matters VS 2010

I have used the WCF Service configuration editor to try and validate what I am doing, still no luck

I get the error after a decent wait 20-30 seconds

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

my web.config is

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    <bindings>
      <basicHttpBinding>
        <binding name="AmjBasicHttpEndpointBinding">
          <security mode="None">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>

    </bindings>
    <behaviors>
      &开发者_如何学Golt;serviceBehaviors>
        <behavior name="SMS.Services.BEIMBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="SMS.Services.BEIMBehavior" name="SMS.Services.BEIM">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="AmjBasicHttpEndpointBinding"
          name="BeimServices" contract="SMS.Services.IBEIM">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

  </system.serviceModel>

EDIT the error message is on the web page. http://Servername/Directory/pageName.svc


Well, it turns out:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

Read the message carefully, and you'll see that you need to enable Anonymous Authentication for the IIS application hosting the service. (In IIS configuration).


WCF transport security for HTTP endpoints hosted in IIS demands that same security setting is applied on your hosting. Go to IIS manager and configure authentication for your hosting application to Windows authentication and turn off other authentication modes.

Well as @Kieren pointed in the comment you set your security mode to None. So you are saying your service that you don't want any security. You should change it to Transport but it will also require HTTPS instead of HTTP endpoint. If you insist on HTTP and you are happy with passing security token over insecure channel you should change it to TransportCredentialOnly.


Have you change the config for your client side? You client side should use the same security mechanism. And please verify that your windows credentials has been passed to server.


I have hosted a WCF in IIS7 in my laptop with Win7. The WCF was using SSL and only basic auth and everything were working. I migrated excactly the same wcf into IIS7 in another machine with Win server 2008 R2 and i got the same error as the post here. The soluton was to comment mex endpoint, and everything is working now. Thank you all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜