This project is read-only.

How to authenticate users against the SQL Membership Provider

J.D. Meier, Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen.

Use the following steps to configure the SQL membership provider to work with UserName authentication in your WCF application:
  1. Configure your SQL server database for membership from a VS 2008 command prompt, run the following command
aspnet_regsql -S .\SQLExpress -E -A m -d <<YourDatabaseName>>

In this command:
  • -S specifies the server, which is (.\SQLExpress) in this example.
  • -E specifies to use Windows Authentication to connect to SQL Server.
  • -A m specifies to add only the membership feature. For simple authentication against a SQL Server user store, only the membership feature is required.
  • -d specifies the SQL server database name. If this option is not used then a default database aspnetdb will be created.
  • For a complete list of the commands, run Aspnet_regsql /?
  • Modify your Web.config file in your WCF service application by adding the following sections
  <add name="MyLocalSQLServer"
       connectionString="Initial Catalog=<<YourDatabaseName>>;
      data source=.\sqlexpress;Integrated Security=SSPI;" />

  <membership defaultProvider="MySqlMembershipProvider" >
      <add name="MySqlMembershipProvider"
           type="System.Web.Security.SqlMembershipProvider" />
  1. Configure the service to use the Username Authentication
    <binding name="wsHttpEndpointBinding">
        <message clientCredentialType="UserName" />
  1. Configure the service to use Membership Provider
    <behavior name="ServiceBehavior">

        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
          membershipProviderName="MySqlMembershipProvider" />


Additional Resources

Last edited May 8, 2008 at 12:58 AM by prashantbansode, version 1


No comments yet.