.NET Framework Bookmark and Share   
 index > Managed Extensibility Framework > How to identify, Is current user a Administrator..?
 

How to identify, Is current user a Administrator..?

Hi,

Is there any registry key using which I can identify that weather the current user is Administrator or not...
I need to do this so that i can exit my Setup if the current user is not an Admin.

Or recoment me if there is some other way to achieve the same.



Thanks,

vishwas Srivastava
Vishwas Srivastava
You can get this information from the WindowsPrincipal class.

Check out this article for a detailed code sample.

The trick here is in the line:
myPrincipal.IsInRole(  WindowsBuiltInRole.Administrator ) ? "True"
 : "False"
,

You can check the current principal to check to see if the current user is an administrator.

Reed Copsey, Jr. - http://reedcopsey.com
  • Proposed As Answer bycautionsign Monday, September 21, 2009 7:00 AM
  •  
Reed Copsey, Jr.

You can use google to search for other answers

Custom Search

More Threads

• Do MEF support WPF elements composition?
• editPoint.get_CodeElement(vsCMElement.vsCMElementEnum) returns null
• not able to call vs 2005 c++ "clr" jni dll in other machines without vs 2005???????
• Comparison of CompositionContainer with traditional IoC Containers
• How to pass an Enum to a Functon
• can we design forms with MAPI to have custom regions in folder view area
• Registry access error in ApplicationBlocks.ExceptionManagement when using Custom Publisher
• No "hard dependancy" but a new dependancy is introduced.
• bxsbankas
• MEF and singletons