1

Sorry if my title's question is not clear. The thing is in my asp.net application I config web.config of folder "Admin" like this:

    <configuration>
      <system.web>
        <authorization>
          <allow roles="Admin" />
          <deny users="*"/>
        </authorization>
      </system.web>
    </configuration>

My database has an table "Account" with 3 fields (Username, password, role). Then I use the login control to login the site of folder "Admin" using code:

    protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
    {
      if(checkUser(Login.Username, Login.Password))
        e.Authenticated = true;
    }

    private bool checkUser(string username, string pass)
    {
      // Check username and pass against database....
    }        

The problem here is that I do not know how to tell the web.config file that the user has "Admin" role. I can fix this problem by using aspnet_regsql which automatically generates several tables in my database, then I log in successfully using Membership.ValidateUser. However, I do not know what happens underground using these built-in database and features. That's why I wonder if it can be solved using custom database above. Thanks in advance.

Tuan van Duong
  • 185
  • 4
  • 14
  • Have you tried searching the net for Creating a Custom Membership Provider? Sounds like that's what you want to do. – nocturns2 Oct 20 '13 at 12:06
  • This post deals with creating a customer membership provider. http://stackoverflow.com/questions/2771094/how-do-i-create-a-custom-membership-provider-for-asp-net-mvc-2 – nocturns2 Oct 21 '13 at 16:07

0 Answers0