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获取用户名、邮箱等?
基础教程推荐
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 如果条件可以为空 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 将数据集转换为列表 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
