問題描述
經過大量研究,我已經讓我的 WPF 應用程序通過 Azure 移動服務登錄用戶.我的移動服務連接到我設置的 Azure Active Directory.但是,當我使用 MobileServiceClient.LoginAsync(...) 登錄用戶時,MobileServiceUser UserId 似乎處于不可讀的哈希中.例如,它看起來像: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.您需要創建一個服務來通過服務公開您的 AAD 信息,并使用您從用戶那里獲得的訪問令牌檢索附加信息.
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;
這將為您提供訪問令牌和 objectID ,然后您需要通過 AAD 圖形 API 查詢信息.https://msdn.microsoft.com/library/azure/dn151678.aspx查看示例請求部分.您應該向查詢提供您獲得的訪問令牌和 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.
這篇關于如何從MobileServiceUser獲取用戶名、郵箱等?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!