If your users are in a SQL membership store, use the SQL Membership Provider
Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen
If your user information is already stored in the aspnetdb
database, or if you are building the application from scratch, use the SQL Membership provider to authenticate your WCF service clients. The Membership Provider will attempt to authenticate incoming
client credentials against the credentials stored in the SQL Membership database.
The membership feature is a good choice as it allows you to enable user name authentication without writing and maintaining custom code.
The SQL Membership provider is configured in the Service config file. The following example demonstrates a Service SQL Membership Provider configuration.
connectionString="Initial Catalog=aspnetdb;data source=10.3.19.60;Integrated Security=SSPI;"/>
<membership defaultProvider="MySqlMembershipProvider" >
Set your binding to use UserName Authentication as follows
<message clientCredentialType="UserName" />
Set the Service Credentials configuration to use the membership provider with username authentication
The following example demonstrates a client connection to the service:
// Set credentials to Alice
client.ClientCredentials.UserName.UserName = "Alice";
client.ClientCredentials.UserName.Password = "ecilA-123";