471,616 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Testing that my application is being run as administrator

Hi,
I'm a complete beginner regarding authentication/permissions etc and have no
idea what/where to start implementing whatever I need in my C# applications.
I've been trying to find info on the web but I seem to be hopeless at
knowing the correct terminology to get any sort of positive search result.
I've just written a utility application that needs to run a series of third
party installation packages, writes to their inifiles after
installation,start/stop services, reads/writes files, registry etc etc.
Expected to be run on Win 2000, XP and Vista.
My solution was to do a check on application startup that it was being run
as administrator, no idea where to start in doing that, and no idea if
that's needed in Win2000 or XP anyway.
Can anyone help me please? Especially with pointers towards links to noob
aimed articles but some code samples for testing for administrator so i can
at least show the user a warning.
thanks :)

Jun 30 '08 #1
2 2880
On Jun 30, 6:31*am, "Claire" <h...@notonyournelly.coomwrote:
Hi,
I'm a complete beginner regarding authentication/permissions etc and have no
idea what/where to start implementing whatever I need in my C# applications.
I've been trying to find info on the web but I seem to be hopeless at
knowing the correct terminology to get any sort of positive search result.
I've just written a utility application that needs to run a series of third
party installation packages, writes to their inifiles after
installation,start/stop services, reads/writes files, registry etc etc.
Expected to be run on Win 2000, XP and Vista.
My solution was to do a check on application startup that it was being run
as administrator, no idea where to start in doing that, and no idea if
that's needed in Win2000 or XP anyway.
Can anyone help me please? Especially with pointers towards links to noob
aimed articles but some code samples for testing for administrator so i can
at least show the user a warning.
thanks :)
You should check if your current Principal is member of the admin
group:
Take a look at WindowsPrincipal.IsInRole method, you will get all you
need there
Jun 30 '08 #2
>>You should check if your current Principal is member of the admin
group:
Take a look at WindowsPrincipal.IsInRole method, you will get all you
need there
thanks ignacio :)
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();

WindowsPrincipal pr = new WindowsPrincipal(windowsIdentity);

if (!pr.IsInRole(WindowsBuiltInRole.Administrator))

MessageBox.Show(gui.frmProcess_WrongPrivileges);


Jul 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ramprasad Ramamurthy | last post: by
1 post views Thread by Mark Jerde | last post: by
3 posts views Thread by Quickjoin Developer | last post: by
5 posts views Thread by nagar | last post: by
2 posts views Thread by K Viltersten | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

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.