Re: Roles question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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 ***


.



Relevant Pages

  • Re: Oh.... Im just wondering whos seen this stumper...
    ... A guy running code under an account ... read/write effective permissions. ... Now his code fails writing to OTHER ... authentication is written in the script. ...
    (microsoft.public.windows.server.active_directory)
  • Re: EventViewer
    ... When running standalone - I succeed writing to EventViewer. ... but I'm pretty sure there's a setting you can place in the application manifest to declare it as requiring admin rights. ... Running standalone, you can right-click on the program or its shortcut and choose "Run As Administrator". ... You need to do this even if your user account is an admin; otherwise the program is run under the admin user account but with reduced privileges. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Writing to eventlog
    ... > of it is writing to log informations from which table it was readed. ... If your app is running on an intranet server that you or your company ... domain user account and tell your app run under that account. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Writing and the Tower of Babel story
    ... and the Tower of Babel story? ... within the timeframe of the biblical account? ... but isn't it a but odd that most or all writing seems to have begun ...
    (talk.origins)
  • Re: Writing to eventlog
    ... >> end of it is writing to log informations from which table it was readed. ... > a domain user account and tell your app run under that account. ...
    (microsoft.public.dotnet.framework.aspnet)