views:

32

answers:

1

I'm trying to configure AspNetMembershipProvider to be used for authenticating in my WCF service that is using basicHttpBinding. I have following configuration:

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="basicSecureBinding">
        <security mode="Message"></security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
      <serviceBehaviors>      
        <behavior name="MyApp.Services.ComputersServiceBehavior">
          <serviceAuthorization roleProviderName="AspNetSqlRoleProvider" principalPermissionMode="UseAspNetRoles" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

      </serviceBehaviors>
  </behaviors>
  <services>
      <service behaviorConfiguration="MyApp.Services.ComputersServiceBehavior" name="MyApp.Services.ComputersService">
          <endpoint binding="basicHttpBinding" contract="MyApp.Services.IComputersService" />
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
  </services>
</system.serviceModel>

Roles are enabled and membership provider is configured (its working for web site).

But authentication process is not fired at all. There is no calles to data base during request, and when I try to set following attribute on method:

 [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
 public bool Test()
 {
     return true;
 }

I'm getting access denied exception. Any thoughts how to fix it?

+2  A: 

Try this CodePlex Security Guide, the How Tos and Application Scenarios have detailed setup and configurations guides for a number of configuration options that might help you find the missing piece of your puzzle.

Tanner

related questions