Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 11, 2012 06:30 PM by mm10
Apr 10, 2012 09:57 PM|LINK
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.
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:
By default membership information for an ASP.NET application is managed by the SqlMembershipProvider.
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.
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.