問(wèn)題描述
經(jīng)過(guò)大量研究,我已經(jīng)讓我的 WPF 應(yīng)用程序通過(guò) Azure 移動(dòng)服務(wù)登錄用戶.我的移動(dòng)服務(wù)連接到我設(shè)置的 Azure Active Directory.但是,當(dāng)我使用 MobileServiceClient.LoginAsync(...) 登錄用戶時(shí),MobileServiceUser UserId 似乎處于不可讀的哈希中.例如,它看起來(lái)像:Aad:X3pvh6mmo2AgTyHdCA3Hwn6uBy91rXXXXXXXXXX".這究竟是什么?
After a lot of digging around I've got my WPF application signing users in via Azure Mobile Service. My Mobile Service is connected to an Azure Active Directory that I have set up. However, when I log the user in with MobileServiceClient.LoginAsync(...) the MobileServiceUser UserId is in an unreadable hash it seems. For example it looks like: "Aad:X3pvh6mmo2AgTyHdCA3Hwn6uBy91rXXXXXXXXXX". What exactly is this?
我想獲取用戶的顯示名稱以使用,但我不知道如何使用.
I'd like to grab the user's display name to use but I can't figure out how.
推薦答案
這是 Azure Active Directory 的用戶 ID.您需要?jiǎng)?chuàng)建一個(gè)服務(wù)來(lái)通過(guò)服務(wù)公開(kāi)您的 AAD 信息,并使用您從用戶那里獲得的訪問(wèn)令牌檢索附加信息.
That is the userID of Azure Active Directory. You need to create a service to expose your AAD info through a service and retrieve the additional information using the access token you get from your user.
第一:
ServiceUser user = this.User as ServiceUser;
var identities = await user.GetIdentitiesAsync();
var aad = identities.OfType<AzureActiveDirectoryCredentials>().FirstOrDefault();
var aadAccessToken = aad.AccessToken;
var aadObjectId = aad.ObjectId;
這將為您提供訪問(wèn)令牌和 objectID ,然后您需要通過(guò) AAD 圖形 API 查詢信息.https://msdn.microsoft.com/library/azure/dn151678.aspx查看示例請(qǐng)求部分.您應(yīng)該向查詢提供您獲得的訪問(wèn)令牌和 objectId.
This will give you the access token and objectID , then you need to query the information through AAD graphy API. https://msdn.microsoft.com/library/azure/dn151678.aspx Look at the sample request part. You should provide the query with the access token you got and objectId.
這篇關(guān)于如何從MobileServiceUser獲取用戶名、郵箱等?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!