Forms Authentication - Add User to Role
Posted on 2011-09-28
Using VS2010 ASP.NET with VB.NET Code
I'm developing a web site using ASP.NET that will use Forms Authentication to authenticate users.
I have an existing back end database that has a table of users with user name and password along with a field that represents their "role" for the web site. I cannot alter the back end database so what I'm trying to do is implement Forms Authentication with Roles without using the Membership or Roles API.
in the code for my Login page, I do the following
- User clicks the 'Login' button.
- Pass their username and password to a customer data object that runs a stored procedure to see if this matches the user table in the database.
- The data object returns "Yes" if the username and password is authenticated as well as the user's "role"
- Set the FormsAuthentication.SetAuthCookie to authenticate the users and they are transferred to the sites home page.
During this login process, how to I assign the "role" to the authenticated user?