I want to create a program that can only be run by a user with administrator
privileges (ie in the BUILTIN/Administrators group - I think. Correct me if
I'm wrong, I'm a bit hazy on users and groups). I'm not sure where to start.
Can someone point me in the right direction. I'm using VS2005 (just upgraded
from 2003)
--
Dave 8 1491
Hello Dave,
just set only Administrator in the Security tab of the your app file property.
or google, as usual :) http://groups.google.com/group/micro...ba8acd180775fe
DI want to create a program that can only be run by a user with
Dadministrator privileges (ie in the BUILTIN/Administrators group - I
Dthink. Correct me if I'm wrong, I'm a bit hazy on users and groups).
DI'm not sure where to start. Can someone point me in the right
Ddirection. I'm using VS2005 (just upgraded from 2003)
D>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Dave,
Try this.
WindowsPrincipal prin = new WindowsPrincipal(
WindowsIdentity.GetCurrent() );
if ( !prin.IsInRole( WindowsBuiltInRole.Administrator ) ) {
MessageBox.Show( "You're not an admin!" );
}
HTH
Andy
Dave wrote:
I want to create a program that can only be run by a user with administrator
privileges (ie in the BUILTIN/Administrators group - I think. Correct me if
I'm wrong, I'm a bit hazy on users and groups). I'm not sure where to start.
Can someone point me in the right direction. I'm using VS2005 (just upgraded
from 2003)
--
Dave
Andy wrote:
Dave,
Try this.
WindowsPrincipal prin = new WindowsPrincipal(
WindowsIdentity.GetCurrent() );
if ( !prin.IsInRole( WindowsBuiltInRole.Administrator ) ) {
MessageBox.Show( "You're not an admin!" );
}
HTH
Andy
Dave wrote:
>I want to create a program that can only be run by a user with administrator privileges (ie in the BUILTIN/Administrators group - I think. Correct me if I'm wrong, I'm a bit hazy on users and groups). I'm not sure where to start. Can someone point me in the right direction. I'm using VS2005 (just upgraded from 2003) -- Dave
The OP seems to have posted his question twice, and I wrote a response in
the other one about something like this.
Your code is very, _very_ nice. I like it, but the inherent flaw is, that
given this application, I could now disassemble it, remove the conditional
(or simply negate the expression) and reassemble it, thus giving me access
to the program.
--
Hope this helps,
Tom Spink
Tom Spink wrote:
Your code is very, _very_ nice. I like it, but the inherent flaw is, that
given this application, I could now disassemble it, remove the conditional
(or simply negate the expression) and reassemble it, thus giving me access
to the program.
Likewise, the user can change the security settings on the file (since
the user is likely an admin). This is much easier to do than decompile
a .Net program and remove the expression. Also, the program gets to
run and thus display a friendly message than 'Access is denied.'
Decompiling a .Net program is always a risk, regardless of what your
code is doing.
Andy wrote:
>
Tom Spink wrote:
>Your code is very, _very_ nice. I like it, but the inherent flaw is, that given this application, I could now disassemble it, remove the conditional (or simply negate the expression) and reassemble it, thus giving me access to the program.
Likewise, the user can change the security settings on the file (since
the user is likely an admin). This is much easier to do than decompile
a .Net program and remove the expression. Also, the program gets to
run and thus display a friendly message than 'Access is denied.'
Decompiling a .Net program is always a risk, regardless of what your
code is doing.
Hi Andy,
Likewise, the user can change the security settings on the file (since
the user is likely an admin).
But if the measures are to prevent non-admins from executing the file, then
that's not an issue, as the non-admins shouldn't have permission to alter
the security settings on that file; and the admins should know better, than
to alter the permissions, if it's a sensitive application.
Also, the program gets to
run and thus display a friendly message than 'Access is denied.'
That is particularly sweet.
--
Hope this helps,
Tom Spink
Hi Guys. Thanks for your replies. I posted twice because I was told I had an
error the first time. The UI on these message boards is DIRE - the link from
the notification email never works, the double click on a thread never works,
and quite often the whole message board doesn't work. And it tells you
there's an error and then posts anyway!
However, to the problem in hand - I can see both your points, however, if I
were going to follow Tom's advice and set the security permissions I would
want to do it as part of the installation - so how would I set that up with
the VS2005 installation pacckager.
Actually, what I would also really like to do is ensure that the app can
only be *installed* by an administrator - is that possible with VS2005?
--
Dave
"Tom Spink" wrote:
Andy wrote:
Tom Spink wrote:
Your code is very, _very_ nice. I like it, but the inherent flaw is,
that given this application, I could now disassemble it, remove the
conditional (or simply negate the expression) and reassemble it, thus
giving me access to the program.
Likewise, the user can change the security settings on the file (since
the user is likely an admin). This is much easier to do than decompile
a .Net program and remove the expression. Also, the program gets to
run and thus display a friendly message than 'Access is denied.'
Decompiling a .Net program is always a risk, regardless of what your
code is doing.
Hi Andy,
Likewise, the user can change the security settings on the file (since
the user is likely an admin).
But if the measures are to prevent non-admins from executing the file, then
that's not an issue, as the non-admins shouldn't have permission to alter
the security settings on that file; and the admins should know better, than
to alter the permissions, if it's a sensitive application.
Also, the program gets to
run and thus display a friendly message than 'Access is denied.'
That is particularly sweet.
--
Hope this helps,
Tom Spink
Likewise, the user can change the security settings on the file (since
the user is likely an admin).
But if the measures are to prevent non-admins from executing the file, then
that's not an issue, as the non-admins shouldn't have permission to alter
the security settings on that file; and the admins should know better, than
to alter the permissions, if it's a sensitive application.
That is assuming the application is deployed in a business environment,
in which case you may be totally right (at my current employer,
everyone has admin rights to thier machine though.. I suspect we are
not alone.). The program in question could be a home user product,
which simply requires admin rights to do something. In that case, the
user likely can become the administrator, and more uses know of file
security settings than know how to decompile a .Net application, remove
the check, and then recompile it.
Just some things to consider. :-)
Andy
Dave, I would advise against going Tom's route (see my other reply
today), unless the application is an internal one for your business,
and normal users aren't admins of there boxes (in some companies, like
mine, they are.. no, they shouldn't be, but that's how it is).
However, if that's really the route you want (or if you need any other
custom actions during your installation, unrelated to this issue), what
you do is add an Installer class. The on the installer class you
create, override the install method. From that method, you can execute
CACLS to modfy the ACL. Or, if you're using .Net 2.0, you can use the
ACL classes within the .Net framework to change the permissions.
HTH
Andy
Dave wrote:
Hi Guys. Thanks for your replies. I posted twice because I was told I had an
error the first time. The UI on these message boards is DIRE - the link from
the notification email never works, the double click on a thread never works,
and quite often the whole message board doesn't work. And it tells you
there's an error and then posts anyway!
However, to the problem in hand - I can see both your points, however, if I
were going to follow Tom's advice and set the security permissions I would
want to do it as part of the installation - so how would I set that up with
the VS2005 installation pacckager.
Actually, what I would also really like to do is ensure that the app can
only be *installed* by an administrator - is that possible with VS2005?
--
Dave
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Worth |
last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0
was able to shut down or restart the (windows XP) machine using a series of
API calls. (Getlasterror, GetCurrentProcess,...
|
by: Philip Wagenaar |
last post by:
I have a program that has to run under the administrator
account. But the use that will start the program has it's
own (limited) account.
How can I run a program under administrator?
I'd like...
|
by: Cleyton |
last post by:
Hello!
Someone knows how I can solve it: I've installed my program in administrator
account for all users. But i've tried to run in guest account, my program
returned fatal error, and it didn't...
|
by: dwalker0229 |
last post by:
I have built a program that uses ultr@vnc for my work. how can i have the program ask for credentials (either run as local user or as "Administrator") but not "require" administrator logon? I want my...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |