Using the below code I am able to get the list of all signed in users. Is there a way to know which is the current active user?
IReadOnlyList<User> users = await Windows.System.User.FindAllAsync();
Using the below code I am able to get the list of all signed in users. Is there a way to know which is the current active user?
IReadOnlyList<User> users = await Windows.System.User.FindAllAsync();
I recently ran into this problem myself, and posted about it here. Someone responded there, and gave me some pretty big hints, which in turn helped me to get this solved.
Here is the quick and dirty (my UWP is HTML/JavaScript based BTW):
First, include the WinJS library in your project, if you don't already have it. Then, you just need a little bit of code to grab the active user, when the application is launched...
WinJS.Application.addEventListener('activated', function (args) {
args.detail.user // <-- the active user!!
});
In order for this to be of any use, you need to grant your VS Solution, the "userAccountInformation" capability. To do that: