PC Review


Reply
Thread Tools Rate Thread

How can i found out the current user's role/permission level

 
 
MJB
Guest
Posts: n/a
 
      24th Jul 2003
I know I can get the current username through the System.Environment class,
but I can't seem to find where I can retrieve the user's role / permission
level (i.e. Admin, power user, etc).

If anyone has done this and can shed some light on the issue I would
appreciate it.

TIA,
Matt


 
Reply With Quote
 
 
 
 
Tom Vande Stouwe MCSD.net
Guest
Posts: n/a
 
      24th Jul 2003
What you can get is the Groups that the user is in with theUser.IsInRole.
You will need to know what permission the groups have, but that is all that
is available to the IDE

Tom

--
==========================================
= Tom Vande Stouwe MCSD.net, MCAD.net, MCP
= 45Wallstreet.com (www.45wallstreet.com)
= (803)-345-5001
==========================================
= If you are not making any mistakes
..= ..you are not trying hard enough.
==========================================
"MJB" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I know I can get the current username through the System.Environment

class,
> but I can't seem to find where I can retrieve the user's role / permission
> level (i.e. Admin, power user, etc).
>
> If anyone has done this and can shed some light on the issue I would
> appreciate it.
>
> TIA,
> Matt
>
>



 
Reply With Quote
 
BenoitM
Guest
Posts: n/a
 
      25th Jul 2003
in addition to what Tom said, with IsInRole , you must know the group name,
as there's no mechanism to retrieve all the group to which a user belongs.

you can use reflection to retrieve the list of all the groups a user belongs
to, but it should not be used in production app since it require elevated
previleges (bcoz of Reflection). Anyway it's a cool way to retrieve the
exact name of all the groups...

----- C# code ----

System.Security.Principal.WindowsIdentity WI =
System.Security.Principal.WindowsIdentity.GetCurrent();

System.Security.Principal.WindowsPrincipal WP = new
System.Security.Principal.WindowsPrincipal(WI);

Type TT = WP.GetType();
FieldInfo PI = TT.GetField( "m_roles",BindingFlags.NonPublic |
BindingFlags.Instance );

string[] ROLES = (string[])PI.GetValue(WP);
string AllRoles="";
foreach (string Role in ROLES)
{
AllRoles +=Role + "\n";
}
MessageBox.Show( AllRoles);

-----


hope it helps


"Tom Vande Stouwe MCSD.net" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What you can get is the Groups that the user is in with theUser.IsInRole.
> You will need to know what permission the groups have, but that is all

that
> is available to the IDE
>
> Tom
>
> --
> ==========================================
> = Tom Vande Stouwe MCSD.net, MCAD.net, MCP
> = 45Wallstreet.com (www.45wallstreet.com)
> = (803)-345-5001
> ==========================================
> = If you are not making any mistakes
> .= ..you are not trying hard enough.
> ==========================================
> "MJB" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > I know I can get the current username through the System.Environment

> class,
> > but I can't seem to find where I can retrieve the user's role /

permission
> > level (i.e. Admin, power user, etc).
> >
> > If anyone has done this and can shed some light on the issue I would
> > appreciate it.
> >
> > TIA,
> > Matt
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpContext.Current.User returns null (forms authentification); how to use custom role and membership providers together? alexandis@gmail.com Microsoft ASP .NET 4 1st Nov 2007 09:56 AM
Role of current windows login user Mark White Microsoft C# .NET 8 16th Jan 2006 05:18 PM
determine table level permission for a user dbuchanan Microsoft Dot NET Framework Forms 0 21st Jun 2005 11:33 AM
Role-based security: Access the role of current user Jesper Stocholm Microsoft ASP .NET 2 23rd Aug 2003 07:59 PM
How can i found out the current user's role/permission level MJB Microsoft C# .NET 2 25th Jul 2003 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.