Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4551978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:42:42+00:00 2026-05-21T16:42:42+00:00

There are a few threads here at so about this matter but most of

  • 0

There are a few threads here at so about this matter but most of them are outdated and the reference links in them are even more outdated.

I got this website which I need to connect to an external sql server (mssql) with it’s own table structure, using the default asp.net membership provider structure is not an option. The table layout is really simple and the usertable looks like this (it’s called Individuals)

Individuals
- UserGuid (uniqueidentifier/guid, unique)
- Name (varchar)
- Password (varchar)
- HasAccess (tinyint/ 1 or 0)
- DateTime (datetime)
- Log (xml)

The required functionality is simply to log someone in, the rest is not necessary 🙂

I followed some guides but most of them are outdated and very complex. Unfortunately the msdn examples follows this pattern and the documentation is not very good.

So if anyone got some resources showing how to, or are willing to post codesamples or similar here I’d appreciate it.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:42:43+00:00Added an answer on May 21, 2026 at 4:42 pm

    It’s very simple really:

    1. Create a new Class file (if you’re not using a multi-layered system, in your project’s Models folder) let’s called MyMembershipProvider.cs

    2. Inherit that class from System.Web.Security.MembershipProvider

    3. automatically create the needed methods (period + space in the inherit class)

    Done!

    All methods will have the NotImplementedException exception, all you need to do is edit each one and put your own code. For example, I define the GetUser as shown below:

    public override MembershipUser GetUser(string username, bool userIsOnline)
    {
        return db.GetUser(username);
    }
    

    dbis my Database Repository that I added into the class as

    MyServicesRepository db = new MyServicesRepository();
    

    there, you will find the GetUser method as:

    public MembershipUser GetUser(string username)
    {
        OS_Users user = this.FindUserByUsername(username);
    
        if (user == null)
            return
            new MembershipUser(
                providerName: "MyMembershipProvider",
                name: "",
                providerUserKey: null,
                email: "",
                passwordQuestion: "",
                comment: "",
                isApproved: false,
                isLockedOut: true,
                creationDate: DateTime.UtcNow,
                lastLoginDate: DateTime.UtcNow,
                lastActivityDate: DateTime.UtcNow,
                lastPasswordChangedDate: DateTime.UtcNow,
                lastLockoutDate: DateTime.UtcNow);
    
        return
            new MembershipUser(
                providerName: "MyMembershipProvider",
                name: user.username,
                providerUserKey: null,
                email: user.email,
                passwordQuestion: "",
                comment: "ANYTHING you would like to pass",
                isApproved: true,
                isLockedOut: user.lockout,
                creationDate: user.create_date,
                lastLoginDate: user.lastLoginDate,
                lastActivityDate: user.lastActivityDate,
                lastPasswordChangedDate: user.lastPasswordChangedDate,
                lastLockoutDate: user.lastLockoutDate);
    }
    

    Do this for all the methods you use (debug the project and see which ones you need) – I only use some, not all as I don’t really care about methods like ChangePasswordQuestionAndAnswer, DeleteUser, etc

    just make sure that in your web.config you add the new Membership as:

    <membership defaultProvider="MyMembershipProvider">
      <providers>
        <clear/>
        <add name="MyMembershipProvider" type="Your.NameSpace.MyMembershipProvider" connectionStringName="OnlineServicesEntities"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>
    

    You have a nice Video Tutorial from Chris Pels (dated 2007 but still mostly valid) and code for this as well, though Video Tutorial is in VB, but let’s you understand the steps…

    http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider

    I did not only create my own Membership Provider but I created my Roles Provider as well, witch as you can see from above code, is as simple as the MemberShip and let’s you, in your application use things like:

    [Authorize(Roles = "Partner, Admin")]
    public ActionResult MyAction()
    {
    
    }
    

    and

    @if (Roles.IsUserInRole(Context.User.Identity.Name, "Admin"))
    {
        <div>You're an ADMIN, Congrats!</div>
    }
    

    What is automagically create the needed methods (period + space in the inherit class)

    You can either right-click, or have the cursor on the name and press Control + . and then space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there have been a few threads on this before, but I have
There are a few posts about this, but after hours of searching I still
There are a few questions about configuring Apache for local development, such as this
I've read through a few other threads on here, though none of them really
I'm learning about POSIX threads right now, but I guess this is just a
There are a few ways to get class-like behavior in javascript, the most common
There are a few books about specific ORM products such as Hibernate or Linq
I've seen there are a few of them. opencvdotnet , SharperCV , EmguCV ,
I've asked here a ton of questions about WSAAsyncSelect and NET.Few months ago I
There are a few things that I almost always do when I put a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.