Solved

Is user running as administrator in Vista?

Posted on 2008-10-27
4
180 Views
Last Modified: 2010-04-21
How can I tell if the user id either running as administrator under Vista, or has UAC disabled?  (I have a reminder message that I display and if either of the above are true, then I don't want to display the message)
0
Comment
Question by:rmmarsh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
jangins101 earned 250 total points
ID: 22818239
You can try just checking to see if the user is in the local administrator's group by getting the current WindowsPrincipal  and checking to see if it's in the Administrators role.
(http://www.danielmoth.com/Blog/labels/UAC.html)

// using System.Security.Principle;
private bool IsAdmin()
{
    WindowsIdentity id = WindowsIdentity.GetCurrent();
    WindowsPrincipal p = new WindowsPrincipal(id);
    
    return p.IsInRole("Administrators");
}

Open in new window

0
 

Author Comment

by:rmmarsh
ID: 22821332
What about UAC being disabled?  Is there a way to tell that?
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 22821455
0
 

Author Closing Comment

by:rmmarsh
ID: 31510568
Thank you both so much... I really appreciate it...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question