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?

空扰寡人 提交于 2019-12-24 09:15:08

问题


I'm using the v5.3 Live SDK for a Windows 8 Store App (XAML/C#) and I have a question.

  1. In my app, if the user is logged into Windows using a Microsoft Account, then I want to grab the firstname/lastname/Microsoft ID.
  2. 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.


回答1:


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.

http://social.msdn.microsoft.com/Forums/en-US/messengerconnect/thread/f6946851-‌​b495-45f6-95a4-eb3c2a004c0e



来源:https://stackoverflow.com/questions/14803027/live-sdk-v5-3-window-8-how-to-tell-the-difference-between-a-user-logged-in-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!