473,323 Members | 1,570 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,323 software developers and data experts.

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

MJB
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
Nov 15 '05 #1
2 8579
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" <mb*@email.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 15 '05 #2
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.GetCurre nt();

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" <to**@conpro.net> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
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" <mb*@email.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Nov 15 '05 #3

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

Similar topics

3
by: Jon Ley | last post by:
I am having a problem restricting write access to tables in my database. In my database I have a table called, for the sake of argument, 'TableX'. In my SQL Server Logins, I have set up a login...
1
by: New MSSQL DBA | last post by:
hi, can anyone help me out with this report. I need to produce a report for the database level user permission. like for a database: DB_A, I want to output as such: .... other public G ...
2
by: Jesper Stocholm | last post by:
I have implemented role-based security within my ASP.Net application. However, it seems the role is not passed to the authentication ticket I create. I want to use it to display/hide some...
2
by: MJB | last post by:
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...
8
by: Mark White | last post by:
Hey everyone I'm having a great deal of problems finding this information through google and yahoo, so I turn to you on this. I have a Windows app running on XP. I am able to caputre the...
1
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
4
by: alexandis | last post by:
There are tons of articles about custom role and provider membership, but they just tear me apart and confuse :( The situation is following: I use DB2, so I wrote custom role + membership...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.