Re: Roles question
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 4 Jan 2006 10:41:39 -0500
Steven,
Do you allow more than one role per person? If you do, then you need to
account for that, and a switch statement won't handle that.
If the role is renamed, then you have to change your code. I mean,
there has to be some level of consistency somewhere.
If you want, you should define aliases for your roles that you will
always use, that are linked to whatever descriptive names you give them.
However, if you use code based security, it doesn't really help, since the
name of your role has to match with the role that you specify in the
attribute.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Steven Blair" <steven.blair@xxxxxxxxxxxxxx> wrote in message
news:eXmweNUEGHA.1124@xxxxxxxxxxxxxxxxxxxxxxx
>I am writing an application using the ASP.NET Configuration Roles and
> Users.
>
> The problem I have, in my C# I need to work out which type of user just
> logged in. I am currently using:
>
> string[] role = Roles.GetRolesForUser();
>
> This give me a string "Administrator" etc.
>
> My C# code looks like this:
>
> switch(userType)
> {
> case "Administrator":
> //Do soemthing
>
> //and so on...
> }
>
> Has anyone come up with a better way for doing this?
>
> The problems I see with this, if the Role is renamed (would be deleted
> and recreated to be called "Admin" for example or a new Role is added.
>
> Any help / advice on this would be appreciated.
>
> Regards,
>
> Steven
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- Re: Roles question
- From: Steven Blair
- Re: Roles question
- References:
- Roles question
- From: Steven Blair
- Roles question
- Prev by Date: Validating parameters to Web Service
- Next by Date: Re: Switch statement alternative
- Previous by thread: Roles question
- Next by thread: Re: Roles question
- Index(es):
Relevant Pages
|