I ended up asking the same question on the MSDN forums and got an answer there, so I am posting it here just in case it helps anyone else.
LIVE SDK v5.3 & Window 8 - How to tell the difference between a user logged in with a Microsoft Account and user with a local account?
-
09-03-2022 - |
Question
I'm using the v5.3 Live SDK for a Windows 8 Store App (XAML/C#) and I have a question.
- In my app, if the user is logged into Windows using a Microsoft Account, then I want to grab the firstname/lastname/Microsoft ID.
- If they are logged in to Windows using a local account and haven't logged in to my app, then I want to show a 'Login' button, so they can enter their Microsoft account email/password.
I know how to do all that using the Live SDK, but my question is - how can I tell if the user is logged into Windows with a Microsoft account versus a Local Account that hasn't been logged in to the MS account?
I can use the following:
var idAuth = new OnlineIdAuthenticator();
return idAuth.CanSignOut;
but this will return false if either the 2 criteria above is true (and return true if the user is using a local account, but has logged in to my app using Microsoft account details).
In theory, if the above returns false, I can do the following:
LiveAuthClient authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(new List<string>() { "wl.signin" });
if (authResult.Status == LiveConnectSessionStatus.Connected)
{ //Get user info here }
The problem is that this works fine for a user logged into windows using a Microsoft Account - their info is picked up fine, but if it is a user logged into Windows with a local account, then it is going to show the Live Login screen in my app - at that point I don't want to do that, rather just show a logon button in my UI.
Anyone any ideas on how to tell the difference between the 2 criteria above?
Thanks in anticipation, Richard.
Solution