It's simple. Create your class derived from the abstract class MembershipProvider
public class MyMembershipProvider : MembershipProvider
{
}
More at: http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx
Do the same for RoleProvider
if you need it.
public class MyRoleProvider : RoleProvider
{
}
More at: http://msdn.microsoft.com/en-us/library/system.web.security.roleprovider.aspx
Implement only the methods you will use and that's all. Start with ValidateUser()
( http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.validateuser.aspx)
Don't forget to point your provider, that is in this case MyMembershipProvider
to web.config in <system.web> <membership> <providers>
section.
Don't complicated it as in almost every tutorial/blog post out there is doing, it's a simple task.
UPDATE:
In the RoleProvider you only need to implement
public override string[] GetAllRoles()
{
return RoleRepository.GetAllRoles();
}
public override string[] GetRolesForUser(string username)
{
return RoleRepository.GetRolesForUser(username);
}
public override bool IsUserInRole(string username, string roleName)
{
return RoleRepository.IsUserInRole(username, roleName);
}
In the MembershipProvider you only need to implement
public override bool ValidateUser(string username, string password)
{
return MembershipRepository.IsUserValid(username,password);
}
You could always use your own ValidateUser()
method regardless of the method in the MembershipProvider.