简体   繁体   English

如何获得用户的交换/ outlook / office365照片?

[英]How to get user's exchange/outlook/office365 photo?

Our company is on Office 365. So when users sign in to my asp.net mvc website, I'd like to display their photo, like Outlook does. 我们公司在Office 365上。所以当用户登录我的asp.net mvc网站时,我想显示他们的照片,就像Outlook一样。

Where does outlook get the user's photo? outlook在哪里获取用户的照片? And how I can get to it programmatically? 以及如何以编程方式实现它?

I've tried hitting up the ActiveDirectory and fetching the thumbnailPhoto, but it's blank for most users. 我试过点击ActiveDirectory并获取thumbnailPhoto,但对于大多数用户来说这是空白的。 Thus Outlook must be getting it elsewhere. 因此,Outlook必须将其纳入其他地方。 Where and how? 在哪里以及如何?

I've also seen some examples where Microsoft.Office.Interop.Outlook assembly is used (assuming it requires Outlook installed to function). 我还看到了一些使用Microsoft.Office.Interop.Outlook程序集的示例(假设它需要安装Outlook才能运行)。 However, this website runs on a server that doesn't have Outlook installed. 但是,此网站在未安装Outlook的服务器上运行。

I've tried hitting up the ActiveDirectory and fetching the thumbnailPhoto, but it's blank for most users. 我试过点击ActiveDirectory并获取thumbnailPhoto,但对于大多数用户来说这是空白的。 Thus Outlook must be getting it elsewhere. 因此,Outlook必须将其纳入其他地方。 Where and how? 在哪里以及如何?

The user photo is not available in your AD on-premise , because your users most likely haven't stored it there in the first place unless you have provided them with an app which writes it to the AD. 用户照片在您的AD 内部部署中 不可用,因为您的用户很可能首先没有将其存储在那里,除非您为他们提供了将其写入AD的应用程序。

The user photo is available in your AD Azure , because your users most likely are applying their photos in Outlook (or online). 用户照片在你的AD Azure中可用的,因为你的用户最有可能在Outlook(或在线)将他们的照片。

I am assuming that your on-premise AD is being synced with Azure AD via Dirsync or ADConnect utilities. 我假设您的内部部署AD正在通过DirsyncADConnect实用程序与Azure AD 同步 If yes, then actually the photo or thumbnailphoto attributes are synced only one-way (from on-premise to Azure) and are not written back. 如果是,那么实际上photothumbnailphoto属性仅以单向同步(从内部部署到Azure)并且不会被回写。 Reference here for DirSync and here for ADConnect . 这里参考DirSyncADConnect

This is why you are not able to get it out of your AD. 这就是为什么你无法将它从你的AD中拿出来的原因。

How to get user's exchange/outlook/office365 photo? 如何获得用户的交换/ outlook / office365照片?

There are quite a few ways to get the photo from Azure AD: 从Azure AD获取照片的方法有很多种:

  1. Exchange Web Services (EWS): by using the GetUserPhoto operation. Exchange Web服务(EWS):使用GetUserPhoto操作。 Basically sending a SOAP envelope with the email address and size. 基本上发送带有电子邮件地址和大小的SOAP信封。 the XML response will get you the base64-encoded photo contained in the PictureData element XML响应将为您提供PictureData元素中包含的base64编码的照片

  2. Exchange Web Services (EWS Managed API and/or REST API): Basically using the AutoDiscover service to the URL https://outlook.office365.com/ews/exchange.asmx and then connect via EWS.Service.ConnectToService method on the Microsoft.Exchange.WebServices.Data namespace for which you need a reference to the library ( a DLL that you can download from here ). Exchange Web服务(EWS托管API和/或REST API):基本上使用自动发现服务访问URL https://outlook.office365.com/ews/exchange.asmx ,然后通过Microsoft.Exchange.WebServices.Data上的EWS.Service.ConnectToService方法进行连接需要引用库的Microsoft.Exchange.WebServices.Data命名空间( 可以从此处下载的DLL )。 The method remains the same GetUserPhoto and the image is contained in the response in binary. 该方法保持相同的GetUserPhoto ,图像包含在二进制响应中。

  3. Outlook REST API: Basically sending a GET request to the Outlook API ( with the bearer access token ) at the URL https://outlook.office.com/api/{version}/me/photo for your own, and at the URL https://outlook.office.com/api/{version}/users/email@example.com/photo . Outlook REST API:基本上向您自己的URL https://outlook.office.com/api/{version}/me/photo发送GET请求到Outlook API( 带有承载访问令牌 ),以及URL https://outlook.office.com/api/{version}/users/email@example.com/photo You get the photo stream in binary format as the response. 您将获得二进制格式的照片流作为响应。 Don't forget to append $value to get the blob otherwise you'll get the metadata. 不要忘记附加$value来获取blob,否则你将获得元数据。 More details referenced here. 这里引用了更多细节。

  4. Office 365 Unified API (aka Graph): Basically nearly the same as the older API. Office 365 Unified API(又名图形):基本上与旧API相同。 Send a GET request (with bearer token) to the URL https://graph.microsoft.com/{version}/me/photo/ for your own photo and https://graph.microsoft.com/{version}/users/UPN/photo for another user. 发送GET请求(带有持票人令牌)到URL https://graph.microsoft.com/{version}/me/photo/为您自己的照片和https://graph.microsoft.com/{version}/users/UPN/photo为另一个用户。 More or less the same. 或多或少相同。 More details referenced here . 这里引用了更多细节 There is also a sandbox here for you to explore the samples and API references. 这里还有一个沙箱供您探索示例和API参考。 You can also try it out yourself online interactively here ( Don't forget to sign-in before firing your get requests ) 您也可以在这里 交互方式在线尝试(请不要忘记在解除获取请求之前登录

Hope that helps. 希望有所帮助。

Some more references: here , here and here . 更多参考资料: 这里这里这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Office 365 REST API - Outlook用户照片 - Office 365 REST API - Outlook User Photo Outlook for Office365 在发送前向用户显示消息 - Outlook for Office365 Display Message to User Before Sending 尝试使用Microsoft Graph API v1.0查询用户的office365个人资料照片时获取“ErrorAccessDenied” - Getting “ErrorAccessDenied” while trying to query for a user's office365 profile photo using Microsoft Graph API v1.0 Outlook Exchange Office 365:如何从访问令牌获取电子邮件地址? - Outlook Exchange Office 365: How to get email address from access token? 创建属性get-mailbox cmdlet时使用Office365 a / c连接到联机交换时出错 - Error connect to exchange online using of Office365 a/c whencreated property get-mailbox cmdlet Office 365 Outlook API(Exchange管理中心) - Office 365 Outlook API (Exchange Admin Center) 如何为Outlook.com/hotmail/office365帐户添加签名? - How can i add signature to outlook.com/hotmail/office365 account? c# 如何使用 Microsoft Graph API 获取 Office 365 用户照片 - c# how to get office 365 user photo using microsoft graph api Office365 Unified Api-与特定用​​户共享文件并获取文件缩略图 - Office365 Unified Api - Share file with specific user and get file thumbnail 如何从Office365中的日历中仅获取新/更新的事件? - How do I get only the new/updated events from a calendar in Office365?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM