如何从MobileServiceUser获取用户名、邮箱等?

How to get user name, email, etc. from MobileServiceUser?(如何从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获取用户名、邮箱等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to MOQ an Indexed property(如何最小起订量索引属性)
Mocking generic methods in Moq without specifying T(在 Moq 中模拟泛型方法而不指定 T)
How Moles Isolation framework is implemented?(Moles Isolation 框架是如何实现的?)
Difference between Dependency Injection and Mocking Framework (Ninject vs RhinoMocks or Moq)(依赖注入和模拟框架之间的区别(Ninject vs RhinoMocks 或 Moq))
How to mock Controller.User using moq(如何使用 moq 模拟 Controller.User)
How do I mock a class without an interface?(如何模拟没有接口的类?)