Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF - Windows authentication - Security settings require Anonymous

I am struggling hard with getting WCF service running on IIS on our server. After deployment I end up with an error message:

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

I want to use Windows authentication and thus I have Anonymous access disabled. Also note that there is aspNetCompatibilityEnabled (if that makes any difference).

Here's my web.config:

<system.serviceModel>     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />     <bindings>         <webHttpBinding>             <binding name="default">                 <security mode="TransportCredentialOnly">                     <transport clientCredentialType="Windows" proxyCredentialType="Windows"/>                 </security>             </binding>         </webHttpBinding>     </bindings>     <behaviors>         <endpointBehaviors>             <behavior name="AspNetAjaxBehavior">                 <enableWebScript />                 <webHttp />             </behavior>         </endpointBehaviors>         <serviceBehaviors>             <behavior name="defaultServiceBehavior">                 <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />                 <serviceDebug includeExceptionDetailInFaults="true" />                 <serviceAuthorization principalPermissionMode="UseWindowsGroups" />             </behavior>         </serviceBehaviors>     </behaviors>     <services>         <service name="xxx.Web.Services.RequestService" behaviorConfiguration="defaultServiceBehavior">             <endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding"              contract="xxx.Web.Services.IRequestService" bindingConfiguration="default">             </endpoint>             <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"></endpoint>         </service>     </services> </system.serviceModel> 

I have searched all over the internet with no luck. Any clues are greatly appreciated.

like image 273
Rashack Avatar asked Jun 22 '09 12:06

Rashack


People also ask

How do I set anonymous authentication in web config?

In the Connections pane, expand the server name, expand Sites, and go to the level in the hierarchy pane that you want to configure, and then click the Web site or Web application. Scroll to the Security section in the Home pane, and then double-click Authentication.

What is anonymous authentication?

Anonymous authentication gives users access to a website without prompting them for a user name or password. When a user attempts to connect to a public website, the web server assigns the user to the Windows user account called IUSR_computername, where computername is the name of the server on which IIS is running.

How do I provide security to WCF?

To secure an application that runs exclusively on a Windows domain, you can use the default security settings of either the WSHttpBinding or the NetTcpBinding binding. By default, anyone on the same Windows domain can access WCF services. Because those users have logged on to the network, they are trusted.

What is security mode in WCF?

Windows Communication Foundation (WCF) security has three common security modes that are found on most predefined bindings: transport, message, and "transport with message credential." Two additional modes are specific to two bindings: the "transport-credential only" mode found on the BasicHttpBinding, and the "Both" ...


1 Answers

So it seems like pretty common issue. The point is to remove mex from your bindings:

<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"></endpoint> 

Alternativelly you enable Anonymous access in IIS and in your web.config you make sure anonymous access is denied.

Hope this will help some other soul. (I was 100% sure I tried it with mex removed. :-O )

like image 61
Rashack Avatar answered Oct 06 '22 18:10

Rashack