Well, I don't know where to start and how am I going to make you understand exactly what I need, but I am going to try my best.
I am doing my Final Project in ASP.NET 3.5 using Visual Studio 2010 Ultimate and SQL Server 2008 Express Edition.
OK, so here is what I need. I have seperate Database created for my Project. Let's assume that I have designed 2 Tables in my Database called Users and Transactions.
The Users Table will only contain User Account Details including information such as UserID, First Name, Last Name, Username, Password, Email, Mobile Number, Address, Gender and so on.
The Transactions Table will only contain a list of Transactions that Customers perform, such as withdrawals, deposits, transfers and so on which includes a Foreign Key UserID.
Here is the catch. I have been able to add Roles, add users and associate users to as many roles as required using the ASP.NET Web Site Administration Tool.
I have also been able to effectively control access to various resources in my Web Application by using the roles added in the ASP.NET Web Site Administration Tool and everything works like a charm, although I don't know where these Roles and Users are added
in reality, whether in a SQL Server Database or elsewhere, what is the name of the database or the table, what is the structure of the database / Table(s) and so on.
My question is, how would I go about using the list of Users added in my Custom Database in the Users Table and also associate these users to Specific Roles such as "Admins", "RegularEmployees" and "Customers", while making use of the built-in ASP.NET Login
Controls, plus also controlling access to certain restricted web pages in my web application based on the Roles that I just mentioned?
I know it's a really big question and a really complicated one, but I have done my share of research and I haven't found the results to my satisfaction. Hoping that someone here will be able to answer my question.
If you need more information in order to answer my question, such as a code snippet from my app, I'd be more than happy to co-operate.
Wow, that was quick and that's a really long code indeed. A lot of things to override. Thanks anyway. I'll go through it and implement it accordingly.
But, I have one doubt, the example code that is given makes use of ODBC Data Provider. But I want to connect to SQL Server using either Windows Authentication or Mixed Authentication. Will ODBC work even to connect to SQL Server? I taught it was to connect
to other Databases such as the one's provided by Oracle.
Clifford Dha...
0 Points
8 Posts
Forms Authentication using Custom SQL Server Database + Roles Based Authentication
Apr 10, 2012 09:57 PM|LINK
Hi,
Well, I don't know where to start and how am I going to make you understand exactly what I need, but I am going to try my best.
I am doing my Final Project in ASP.NET 3.5 using Visual Studio 2010 Ultimate and SQL Server 2008 Express Edition.
OK, so here is what I need. I have seperate Database created for my Project. Let's assume that I have designed 2 Tables in my Database called Users and Transactions.
The Users Table will only contain User Account Details including information such as UserID, First Name, Last Name, Username, Password, Email, Mobile Number, Address, Gender and so on.
The Transactions Table will only contain a list of Transactions that Customers perform, such as withdrawals, deposits, transfers and so on which includes a Foreign Key UserID.
Here is the catch. I have been able to add Roles, add users and associate users to as many roles as required using the ASP.NET Web Site Administration Tool.
I have also been able to effectively control access to various resources in my Web Application by using the roles added in the ASP.NET Web Site Administration Tool and everything works like a charm, although I don't know where these Roles and Users are added in reality, whether in a SQL Server Database or elsewhere, what is the name of the database or the table, what is the structure of the database / Table(s) and so on.
My question is, how would I go about using the list of Users added in my Custom Database in the Users Table and also associate these users to Specific Roles such as "Admins", "RegularEmployees" and "Customers", while making use of the built-in ASP.NET Login Controls, plus also controlling access to certain restricted web pages in my web application based on the Roles that I just mentioned?
I know it's a really big question and a really complicated one, but I have done my share of research and I haven't found the results to my satisfaction. Hoping that someone here will be able to answer my question.
If you need more information in order to answer my question, such as a code snippet from my app, I'd be more than happy to co-operate.
Clifford Anup Dhamanigi
mm10
Contributor
6399 Points
1184 Posts
Re: Forms Authentication using Custom SQL Server Database + Roles Based Authentication
Apr 11, 2012 07:53 AM|LINK
You should implement a custom membership provider and a custom role provider.
See this link for an example: http://msdn.microsoft.com/en-us/library/6tc47t75.aspx
By default membership information for an ASP.NET application is managed by the SqlMembershipProvider.
Clifford Dha...
0 Points
8 Posts
Re: Forms Authentication using Custom SQL Server Database + Roles Based Authentication
Apr 11, 2012 04:40 PM|LINK
Wow, that was quick and that's a really long code indeed. A lot of things to override. Thanks anyway. I'll go through it and implement it accordingly.
But, I have one doubt, the example code that is given makes use of ODBC Data Provider. But I want to connect to SQL Server using either Windows Authentication or Mixed Authentication. Will ODBC work even to connect to SQL Server? I taught it was to connect to other Databases such as the one's provided by Oracle.
Clifford Anup Dhamanigi
mm10
Contributor
6399 Points
1184 Posts
Re: Forms Authentication using Custom SQL Server Database + Roles Based Authentication
Apr 11, 2012 06:30 PM|LINK
If you connecting against a SQL Server database, use the SqlConnection and SqlCommand classes instead of the OdbcConnection and OdbcCommand classes.