Solved

Is user running as administrator in Vista?

Posted on 2008-10-27
4
175 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
  • 2
4 Comments
 

Accepted Solution

by:
jangins101 earned 250 total points
Comment Utility
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
Comment Utility
What about UAC being disabled?  Is there a way to tell that?
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
Comment Utility
0
 

Author Closing Comment

by:rmmarsh
Comment Utility
Thank you both so much... I really appreciate it...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now