How to get user name, email, etc. from MobileServiceUser?(如何从MobileServiceUser获取用户名、邮箱等?)
问题描述
经过大量研究,我已经让我的 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获取用户名、邮箱等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从MobileServiceUser获取用户名、邮箱等?
基础教程推荐
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
