473,388 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

roles and authentication

I have some code of my own where I am checking a username/password
against a database for login, I am not using any of the login controls
etc. What I want to do next is to create a folder for my admin pages
and make it only available to administrators. At login I set an int
which if an admin logs in is set to 2, otherwise it is set to 1 or 3. So
what I want to be able to do is check if this int is 2, and if so set a
global value which means that the admin pages can be viewed. How do I
do this?
*** Sent via Developersdex http://www.developersdex.com ***
Jun 13 '06 #1
1 938
if you're open to a slightly more complex way of doing this, using
asp.net roleproviders and membershipproviders provides a more built in,
hands off way of doing this.

here's a couple of links to get you started
http://weblogs.asp.net/scottgu/archi...13/442772.aspx - Source
Code for the Built-in ASP.NET 2.0 Providers Now Available for Download
http://www.devx.com/asp/Article/29256 - Writing A Custom Membership
Provider for your ASP.NET 2.0 Web Site

once you've set that up, in order to protect a folder in your website,
all you have to do is add this to that folder's web.config:
// ------ web.config ---------
<configuration>
<system.web>
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
</system.web>
</configuration>

that will alllow users w/ the role 'admin' and deny all the rest ...
you can also use "<users="?" />" to deny unauthorized users. we just
finished updating our website to ouse those, and it helped us strip out
a lot of ugly looking code.

Mike P wrote:
I have some code of my own where I am checking a username/password
against a database for login, I am not using any of the login controls
etc. What I want to do next is to create a folder for my admin pages
and make it only available to administrators. At login I set an int
which if an admin logs in is set to 2, otherwise it is set to 1 or 3. So
what I want to be able to do is check if this int is 2, and if so set a
global value which means that the admin pages can be viewed. How do I
do this?
*** Sent via Developersdex http://www.developersdex.com ***


Jun 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cmrchs | last post by:
Hi, I can't make <allow roles...> to work in web.config I'm logging on as 'Administrator' and try to access a site for which the IIS-authentication method is set to 'Integrated Windows' only ...
4
by: Marty Underwood | last post by:
Okay the subject line explains a scenario I just had to tackle but I am looking for a better way. The current way: 1) Use forms authentication. 2) Query Active Directory and bind to a user...
2
by: Ed | last post by:
Hi I currently have an asp.NET project. I'm using Access 2003 and forms authentication to authenticate users. Can anyone tell me how to set the roles in asp.NET so that it recognizes them? The...
5
by: hansiman | last post by:
Following http://aspnet.4guysfromrolla.com/articles/082703-1.aspx I've set up roles authentication for my web application. User's roles are registered by: HttpContext.Current.User = _ New...
7
by: Matthias S. | last post by:
Hi, here is what I'm trying to do: I have a virtual directory called "WebApp". Under this one I've got 2 physical directories called "Customers" and "Admins". I implemented Forms-based...
2
by: Giammarco | last post by:
Hi all, I'm developing an ASP.NET website and thinking about releasing the API through webservices in a couple of months (like flickr.com let's say). Most of the website functionality is...
1
by: chris.rust | last post by:
Has anyone else had any trouble setting up a sitemap view to be filtered by roles? We've put a cust role provider in place, and we can verify that it's only being called once for each...
2
by: Jules | last post by:
When creating this website I user a custom authentication method to validate the usercredentials (I think the membership provider is an overkill since I only use the authentication part). When I...
5
by: Andrew | last post by:
Hi, I have a default.aspx which allows the user to choose between module Admin and module B. When the user clicks either one, he will be redirected to a FormsAuthentication login page. The...
2
by: mark4asp | last post by:
This is a simplified version of my site. There are Premium users who have access to the Premium directory. Anyone else attempting to access it should be logged and then redirected to the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.