.NET Framework Bookmark and Share   
 index > MSBuild > Share add-in
 

Share add-in

My share add-in application have a automatic detect User Acount Control (UAC) state (On/Off) function. I use this method:

static internal bool IsAdmin()
{

WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);
return p.IsInRole(WindowsBuiltInRole.Administrator);
}
Return true if UAc is Disable
Return false if UAC is Enable
when i use Word 2007 on Vista Ultimate, the received result of IsAdmin() method is always correct
But when i use Word 2003 on Windows Vista Ultimate, IsAdmin() always return "true" eventhough I still enable UAC
Help me resolve this problem!!!

  • Edited byhungnn Wednesday, June 03, 2009 8:41 AM
  • Edited byhungnn Wednesday, June 03, 2009 4:15 AM
  •  
hungnn
Hi Hungnn,

As far as I know, your code sinppet is just for checking whether the current application is running as Administrator, but not checking whether UAC is ON/OFF.

If you enable UAC, the application will run in different levels :User/Adiministrator, you can use Run as Administrator elevating User to Adiministrator, so you will get true or false. But if you disable UAC, it will return one state: User or Administrator.

If you want to check for UAC by application, as far as I know, UAC by design is difficult to check for. We don’t want applications checking for it and acting differently. We want applications to act properly with UAC turned on.

And I highly suggest you post your question in appropriate forum, and you will get better answer.

Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao
Hi Hungnn,

As far as I know, your code sinppet is just for checking whether the current application is running as Administrator, but not checking whether UAC is ON/OFF.

If you enable UAC, the application will run in different levels :User/Adiministrator, you can use Run as Administrator elevating User to Adiministrator, so you will get true or false. But if you disable UAC, it will return one state: User or Administrator.

If you want to check for UAC by application, as far as I know, UAC by design is difficult to check for. We don’t want applications checking for it and acting differently. We want applications to act properly with UAC turned on.

And I highly suggest you post your question in appropriate forum, and you will get better answer.

Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao
Thanks for your suggestion!
hungnn

You can use google to search for other answers

Custom Search

More Threads

• Building an unmanaged .dll into a web application
• "Microsoft.Sdc.Tasks" project is not getting recognized
• Resume build from target X
• msbuild build errors
• Web Deployment Project and Parameters
• MSBuild
• Singleton patter with MSbuild task inherited class.
• How to fix warning MSB9004?
• ResolveAssemblyReference task and how it acts with dependencies found in GAC
• BizTalk Deployment