Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 11th, 2004, 04:07 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Authentication and Role-Based Security

Hi,
I'm using Daniel Cazzulino's excellent book "Beginning C# Web Applications with Visual Studio .NET". In his example in chapter 10 he creates a GenericPrincipal containg the role of a user (which will later show or hide a link to an admin page). Here is a code snippet :

    ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
sql = "SELECT IsAdministrator FROM [User] WHERE UserId='{0}'";
sql = String.Format(sql, id);
cmd = new SqlCommand(sql, con);
con.Open();

object admin = cmd.ExecuteScalar();

// Was it a valid UserID?
if (admin != null)
  {
  GenericPrincipal ppal;
  string[] roles;

    // If IsAdministrator field is true, add both roles
    if (((bool)admin) == true)
        {
        roles = new string[] {"User", "Admin"};
        }
     else
        {
        roles = new string[] {"User"};

........

his role is stored as a boolean and inspected as such. But I have several roles which are probably better stored as int. Has anybody got any advice how I might achieve this? Something like :

int admin = cmd.ExecuteScalar();
.....
if (admin == 1){roles = new string[] {"User", "Approver","Admin"};}
elsif (admin == 2){roles = new string[] {"User", "Approver"};}
else {roles = new string[] {"User"};}

Maybe??
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Role based security tsimsha ASP.NET 2.0 Basics 4 May 6th, 2008 11:41 AM
Code Access Security & Role Based Security robzyc C# 6 April 11th, 2008 02:31 AM
Tag library for field level role based security mmalik_altaf Pro JSP 0 June 7th, 2006 05:02 AM



All times are GMT -4. The time now is 01:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.