I would like to check if current user has administrator rights. I suppose that System.Security.Principal.IIdentity and System.Security.Principal.IPrincipal would be useful, but I have no idea how to implements these interfaces. Please, help me.
Asked
Active
Viewed 514 times
0
-
Not sure you want to *implement those* interfaces aswell, use them. I'm not sure whats considered correct for windows store apps, but in .net apps you get the current user by using 'System.Threading.Thread.CurrentPrincipal' – Marvin Smit Dec 07 '13 at 00:31
-
Unfortunately, there is no System.Threading.Thread.CurrentPrincipal in Windows Store Apps. – mankers Dec 07 '13 at 00:40
-
reformulating the question a little i came upon http://stackoverflow.com/questions/15225486/how-to-get-logged-in-pc-username-in-windows-store-apps. See if that "await UserInformation.????" has what you need – Marvin Smit Dec 07 '13 at 00:43
-
I had seen this tutorial on another website, but I knew it. The problem is, that I need to know if current user has administrator rights and this information is not included in UserInformation class. – mankers Dec 07 '13 at 00:52
-
What will you do differently once you know that the user is an admin? As Kraig Brockschmidt mentioned below, all store apps run in a sandbox and thus can't take any actions that would require administrative rights. – Larry Osterman Dec 08 '13 at 18:42
1 Answers
4
Windows Store apps by design run at base trust, never elevated. Any WinRT API that requires full trust has to be called from an elevated desktop app. Accordingly, your question is somewhat moot, as you'll not be able to do anything differently even if you could determine the admin rights.

Kraig Brockschmidt - MSFT
- 7,004
- 1
- 20
- 23
-
I like your way of thinking, but I really need to get this information. – mankers Dec 07 '13 at 00:55
-
I'm also saying that there is no API to make that determination from a Windows Store app. The Win32 and/or WinRT APIs that you'd use for this are available only to full trust desktop apps, see http://social.msdn.microsoft.com/Forums/windowsapps/en-US/18a1e101-e206-4060-9b3e-db6f113d5524/how-to-get-user-sid-in-metro-style-app?forum=winappswithcsharp. Sorry. – Kraig Brockschmidt - MSFT Dec 08 '13 at 04:20