473,320 Members | 2,112 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,320 software developers and data experts.

User Privileges

Hi all,

I need to know the user privileges (does user have administrator privileges)
..

Which c# api's should i use?

Thanks a lot
Nov 17 '05 #1
4 12864

"Feldman Alex" <ut*****@mail.ru> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi all,

I need to know the user privileges (does user have administrator
privileges)
.

Which c# api's should i use?

Thanks a lot

Please define Administrator privileges.
If a user is a member of the administrators group it has the same privileges
as the administrator suposing administrator is also a member, but that
doesn't mean a lot if someone changed the default administrator privileges.

What privilege are you looking for exactly?

Willy.
Nov 17 '05 #2
Well , I'll describe a full task.
I'm writing a install application, and I need to know that the user have the
privileges to install/write to program files.

Thank you
Alex

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:eN*************@TK2MSFTNGP09.phx.gbl...

"Feldman Alex" <ut*****@mail.ru> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi all,

I need to know the user privileges (does user have administrator
privileges)
.

Which c# api's should i use?

Thanks a lot

Please define Administrator privileges.
If a user is a member of the administrators group it has the same

privileges as the administrator suposing administrator is also a member, but that
doesn't mean a lot if someone changed the default administrator privileges.
What privilege are you looking for exactly?

Willy.

Nov 17 '05 #3

"Feldman Alex" <ut*****@mail.ru> wrote in message
news:ec**************@TK2MSFTNGP15.phx.gbl...
Well , I'll describe a full task.
I'm writing a install application, and I need to know that the user have
the
privileges to install/write to program files.

Thank you
Alex

By default only administrators and power users have write access privileges
to "Program Files", so you could also check group membership for the current
user.
Something like this should do...
AppDomain ad = Thread.GetDomain();
ad.SetPrincipalPolicy(PrincipalPolicy.WindowsPrinc ipal);
WindowsPrincipal user = (WindowsPrincipal)Thread.CurrentPrincipal;
if(user.IsInRole(WindowsBuiltInRole.Administrator) ||
user.IsInRole(WindowsBuiltInRole.Administrator))
{
// Ok, user is power user or administrator
..
}
else
// Non privileged user, not ok to continue...

Another way to determine the access privileges to a folder, is by creating a
dummy file into the folder, if it fails, it's because the user has no write
access privileges.

Willy.
Nov 17 '05 #4
Thank you Willy
You helped me a lot :)

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:eg*************@TK2MSFTNGP12.phx.gbl...

"Feldman Alex" <ut*****@mail.ru> wrote in message
news:ec**************@TK2MSFTNGP15.phx.gbl...
Well , I'll describe a full task.
I'm writing a install application, and I need to know that the user have
the
privileges to install/write to program files.

Thank you
Alex

By default only administrators and power users have write access

privileges to "Program Files", so you could also check group membership for the current user.
Something like this should do...
AppDomain ad = Thread.GetDomain();
ad.SetPrincipalPolicy(PrincipalPolicy.WindowsPrinc ipal);
WindowsPrincipal user = (WindowsPrincipal)Thread.CurrentPrincipal;
if(user.IsInRole(WindowsBuiltInRole.Administrator) ||
user.IsInRole(WindowsBuiltInRole.Administrator))
{
// Ok, user is power user or administrator
..
}
else
// Non privileged user, not ok to continue...

Another way to determine the access privileges to a folder, is by creating a dummy file into the folder, if it fails, it's because the user has no write access privileges.

Willy.

Nov 17 '05 #5

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

Similar topics

1
by: Gary | last post by:
Hello guys! Bear with me,I am newbie. I am trying to limit the privileges of the user PUBLIC has as toughly as possible which means I want to go as far as I can then leave those MUST-HAVE...
1
by: Jani Tamminen | last post by:
We run DB2 UDB v8.1 on Windows. How do I find the list of all users that have the following privileges: 1. User Data Maintenance 2. System Tabale Maintenance
1
by: Taber, Mark | last post by:
I posted this earlier, and got no responses. While using pg_dump and pg_restore (or attempting to restore, more precisely), the process failed because of a missing user, user '128'. I never...
2
by: Ray Muforosky | last post by:
Hello everyone. I created a new user with the grant command and yet, I can't login into the database I must mention that the user was created but all the privileges are set to 'N'. This is...
1
by: menoquindici | last post by:
We have a situation here where one of my co-workers removed several privileges from the 'root' user, namely: INSERT UPDATE DELETE FILE
5
by: Martijn Saly | last post by:
I'd like to test in my script, if it's going to be possible to enable priviliges. If I use this... netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") ....it presents a...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
3
by: Rahul B | last post by:
Hi, I want to grant only the connect, select, insert, update privileges on all the tables of a schema to a particular user/group Initially, i had revoked all the privileges from public. It...
11
by: giddy | last post by:
hi, (I want someone to check if my idea is utterly stupid or ok??) I have a mid complex app for a hotel that needs a fine grained user security system. In other words an admin should be able...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.