久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 Azure Active Directory 獲取個人資料圖片

Get profile picture from Azure Active Directory(從 Azure Active Directory 獲取個人資料圖片)
本文介紹了從 Azure Active Directory 獲取個人資料圖片的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我們已將 Azure AD 設置為應用程序中的身份提供者.我們希望在應用程序中顯示應該來自 Azure AD 的個人資料圖片.

We have set the Azure AD as a identity provider in our application. We want to display profile picture that should come from Azure AD, in the application.

為了測試,我在 Azure AD 中添加了一個 Windows Live Id 帳戶(具有個人資料圖片).然后我們使用 Graph Explorer 進行了嘗試,但沒有成功.

In order to test, I have added one Windows Live Id account (which has a profile picture) in the Azure AD. We then tried it using Graph Explorer, but no luck.

我們如何從 Azure AD 中獲取個人資料圖片?

How do we get the profile picture from Azure AD?

推薦答案

您可以使用 Azure Active Directory Graph Client 獲取用戶縮略圖照片

You can use Azure Active Directory Graph Client to get user thumbnail photo

var servicePoint = new Uri("https://graph.windows.net");
var serviceRoot = new Uri(servicePoint, "<your tenant>"); //e.g. xxx.onmicrosoft.com
const string clientId = "<clientId>";
const string secretKey = "<secretKey>";// ClientID and SecretKey are defined when you register application with Azure AD
var authContext = new AuthenticationContext("https://login.windows.net/<tenant>/oauth2/token");
var credential = new ClientCredential(clientId, secretKey);
ActiveDirectoryClient directoryClient = new ActiveDirectoryClient(serviceRoot, async () =>
{
    var result = await authContext.AcquireTokenAsync("https://graph.windows.net/", credential);
    return result.AccessToken;
});

var user = await directoryClient.Users.Where(x => x.UserPrincipalName == "<username>").ExecuteSingleAsync();
DataServiceStreamResponse photo = await user.ThumbnailPhoto.DownloadAsync();
using (MemoryStream s = new MemoryStream())
{
    photo.Stream.CopyTo(s);
    var encodedImage = Convert.ToBase64String(s.ToArray());
}

Azure AD 以二進制格式返回用戶照片,需要轉換為 Base64 字符串

Azure AD returns user's photo in binary format, you need to convert to Base64 string

這篇關于從 Azure Active Directory 獲取個人資料圖片的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: av一区二区三区四区 | 国产香蕉视频在线播放 | 日本a级大片 | 欧美精品久久一区 | 中文字幕1区2区3区 亚洲国产成人精品女人久久久 | 小草久久久久久久久爱六 | 干干天天 | 精品成人一区二区 | 欧美一区视频 | 中文字幕视频在线看 | 成人精品国产免费网站 | 国产精品福利在线 | 国产精品久久久久久一级毛片 | 日韩精品在线视频 | 黄色免费看 | 日本精品一区二区 | www.男人天堂.com | 91在线一区| 欧美日韩成人 | 欧美一区二区三区在线看 | 欧美三区在线观看 | 日本精品久久久久久久 | 午夜精品一区二区三区免费视频 | 国产精品精品久久久 | 日韩福利| 久久久青草婷婷精品综合日韩 | 欧美激情一区二区 | 亚洲逼院 | 日日碰狠狠躁久久躁婷婷 | 久久精品伊人 | 久久91| 一区视频在线 | 台湾佬成人网 | 成人亚洲在线 | 欧美成人精品 | 成人免费视频观看视频 | 欧美成人精品一区二区男人看 | 欧美成人二区 | 中文字幕高清av | 免费99精品国产自在在线 | 国产精品毛片一区二区三区 |