0
votes

I'm trying to implement a customer ASP.NET Membership provider. I have no database yet, but I know I want one that's simple and accessible.

I know I don't want to use the generated tables because from what I've seen and understand, they are very convoluted and include many fields that I just won't need. I set up the default Membership provider and let it generate its own database/tables and it produced this:

enter image description here

All by itself. I don't want this mess as part of my database. So the natural solution? A custom membership provider. To do this, I know you need to inherit from System.Web.Security.MembershipProvider and setup web.config to the derived class that I create.

public class MessAround : System.Web.Security.MembershipProvider
{
public MessAround()
{

    //
    // TODO: Add constructor logic here
    //
}

public override string ApplicationName
{
    get
    {
        throw new NotImplementedException();
    }
    set
    {
        throw new NotImplementedException();
    }
}

public override bool ChangePassword(string username, string oldPassword,

 string newPassword)
{
    throw new NotImplementedException();
}

public override bool ChangePasswordQuestionAndAnswer(string username
, string password, string newPasswordQuestion, string newPasswordAnswer)
{
    throw new NotImplementedException();
}

....ETC ETC ETC

My question is:

  • How do I integrate this class into a custom database schema?

  • How do I eliminate fields that I don't need?

  • How do I get this class to interact with my database tables?

  • WTF is going on? :P

1
In the generate class, just remove throw new NotImplementedException(); from the methods you will use and instead add you own implementaion in them. Those methods you will not need you can leave as is with the throw. Check this answer to get started: stackoverflow.com/a/5702000/1429080user1429080

1 Answers

1
votes

First of all, The whole ASP.Net Membership is inbuilt functionality. So there is pros and cons comes as

Pros

  • easy to use and implement
  • give all functionality of user management
  • automatically create UI, DB and relationship.

Cons

  • customization is tedious job.
  • after implementation to whole systam, to remove whole thing will make issue.

Now I give the answer one by one.

  1. How do I integrate this class into a custom database schema? For schema use, the rule is always use schema-name before object like yourschema.sp_name
  2. How do I eliminate fields that I don't need? You can't remove fields as one or more reference of fields. Why you remove fields, you just left that. I also found the same issue, in that I left and only use which I want.
  3. How do I get this class to interact with my database tables? If you are using Entity-Framenwork or linq, its get as a class of your table. Which type of interact you need? for login- logout or session management. Then check this link:

How to Check whether Session is Expired or not in asp.net

Using session variable with ASP.Net membership provider