-1

There are plenty of examples for Windows Desktop apps that will say whether or not the current user is an Admin.

Here are two

My problem is that I need to check within a Windows 8 Store App and they have a subset of the main .NET api. The stuff around Principals and Role are missing. The Windows.System.UserProfile.UserInformation class looked promising but that was a dead end.

Can it be done?

Thanks

Pat Long - Munkii Yebee
  • 3,592
  • 2
  • 34
  • 68

1 Answers1

0

This is useless, because Store Apps don't run when you have an account with full admin rights.

enter image description here

The Sandbox around the Apps requires UAC/ filtered rights. So your apps get never full admin rights and you can skip this check.

magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • If I read you correctly you are saying a store app will not run when your account is a full administrator. Is that what you are saying? That means you are also saying that API, which requires admin rights, is never going work. – Pat Long - Munkii Yebee Jul 21 '14 at 06:36
  • correct, store apps can never run as admin. You'll see this message: http://teamwindows8.com/wp-content/uploads/2013/04/uac-metro-app.png – magicandre1981 Jul 21 '14 at 17:54
  • I don't want to RUN as admin I wanted to be able to find if the current user IS an admin. You have said "Store Apps don't run when you have an account with full admin rights" yet I sit here on my 8.1 machine as a local admin running Window Store Apps just fine. After reading the EAS Compliance Docs (http://msdn.microsoft.com/en-us/library/windows.security.exchangeactivesyncprovisioning.eascomplianceresults.Aspx) close I can in fact see that it will come back and tell me if I am not an Adminstrator so I no longer need any other way of checking – Pat Long - Munkii Yebee Jul 21 '14 at 18:33
  • this makes no difference. With the UAC you get 2 tokens for admin users (http://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx). All applications run with the filtered token so all API calls will tell you limited/standard users. When you disable the UAC your app will no longer work. Why do you want to know? – magicandre1981 Jul 22 '14 at 19:59
  • Why do I want to know why the user is an Admin or not? I want to know because I do not want to call ApplyAsync (http://msdn.microsoft.com/en-us/library/windows.security.exchangeactivesyncprovisioning.easclientsecuritypolicy.applyasync.Aspx) with a user that is not an Admin. Doing so throws an Exception – Pat Long - Munkii Yebee Jul 23 '14 at 05:15
  • this is terrible design. Add try/catch around it and handle the thrown exception correctly. – magicandre1981 Jul 23 '14 at 19:01