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

administrative user or limited user

Hi,
I have a C# program that need to know whether the user that run the
application is administrative user or limited user.
Are there any methods in C# I can use?
--
windsim
Jul 17 '07 #1
2 1929
"windsim" <wi*****@discussions.microsoft.comwrote in message
news:FC**********************************@microsof t.com...
I have a C# program that need to know whether the user that run the
application is administrative user or limited user.
Are there any methods in C# I can use?
AppDomain myDomain = Thread.GetDomain();
myDomain.SetPrincipalPolicy(PrincipalPolicy.Window sPrincipal);
WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
bool isAdmin=myPrincipal.IsInRole(WindowsBuiltInRole.Ad ministrator);
Jul 17 '07 #2
On Tue, 17 Jul 2007 00:50:03 -0700, windsim
<wi*****@discussions.microsoft.comwrote:
Hi,
I have a C# program that need to know whether the user that run the
application is administrative user or limited user.
Are there any methods in C# I can use?
Since you already got an answer to the actual question, I will offer this:

Why do you think you need to know whether the user is an administrator or
not?

I have run into applications that do this sort of check, and they always
wind up confounding my attempts to maintain a secure system. They are
generally written wrong in the first place, insisting on having access to
areas of my computer that they don't need access to for normal operation,
and by checking my user type explicitly, they negate any attempt on my
part to provide narrowly-defined access to the specific resources they
want without exposing the rest of my computer to the application.

IMHO, there are at least two different ways you can address the usual
things related to admin/limited user rights:

1) Simply try to access to resource and see if it succeeds or fails.
IMHO, this is the best, as it allows complete flexibility on the part of
the user with respect to managing how the application runs. They can
provide the necessary access as necessary, and/or take advantage of
Vista's virtualization features to allow the application to run.

2) Check the user credentials for the resource directly (see "access
control list"). This may defeat attempts by the user to allow
virtualization of the resource, but at least the user can still open
access to the specific resource your application requires without having
the application demand full administrator rights when it doesn't really
need them.

In either case, of course, it is imperative that you provide a useful
error message to the user so that they know what resource it is your
application is trying to access, so that they can change the security
settings as necessary.

Even better, of course, would be to fix your application so that it
doesn't matter whether an admin or limited user is running the application.

Pete
Jul 17 '07 #3

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

Similar topics

1
by: M Yager | last post by:
Hi all, I've found a little issue that i'm not sure what to do about. My machine has 2000 server on it. It's running a little asp / vb dll app. Ok, now say you log in to the app from a...
2
by: John Smity | last post by:
Does anyone have any links or ideas on how you bunch together all your administrative pages? Currently I have 10-20 different options that users can configure (add/change/delete) and it is...
5
by: charles leviton | last post by:
I am trying to install UDBv7.2 FP 5 on a Windows XP Pro box. It uses a response file that has a userid and password in it. This user id has been set up as a user on my m/c under the group...
3
by: sea | last post by:
In order to have System Administrator privileges for the DB2 database, is it necessary to have Administrative access (log on as administrator) on the computer where DB2 is installed? Or, if a...
1
by: Sushant Bhatia | last post by:
Hi. I'm working at Arizona State University on a project that is developing software for individuals who are blind and I need to be able to setup an App that we are creating to run with...
2
by: NAGY | last post by:
hello, I created an asp.net web app in C# from a non administrative account in Visual Studio 2003, .net 1.1. when i try to run the application in debug mode from Debug start menu option, i get an...
1
by: rajeshwarrao.g | last post by:
Hi All, I am trying to access MSDE from ASP.NET application without giving administrative privileges to ASPNET user. It gives an error message saying "Cannot login to SQL server for ASPNET"....
0
by: cryinlion85 | last post by:
if i have administrative privileges on a machine, is it possible through File methods to open a file for I/O under a different user account? here's my situation, please read through before replying:...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.