久久久久久久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手机免费在线观看 | 国产一区二区三区色淫影院 | 国产极品粉嫩美女呻吟在线看人 | 91久久久久久久久久久久久 | 国产乱性| 久久精品99久久 | 成人在线视频网站 | 欧美综合在线观看 | 在线成人| 久久久片 | 一本大道久久a久久精二百 国产成人免费在线 | 美女在线观看国产 | 在线看成人av | 久久精品一区二区 | 天堂精品 | 精品视频在线播放 | 国产美女一区二区三区 | 亚洲精彩视频 | 人人做人人澡人人爽欧美 | 中文字幕一区二区三区精彩视频 | 欧美亚洲国产一区 | 一级大黄色片 | 成人不卡 | 欧美理论 | 亚洲精品电影网在线观看 | 午夜爽爽爽男女免费观看 | 成人3d动漫一区二区三区91 | 视频一区中文字幕 | 天天躁日日躁aaaa视频 | 亚洲激情专区 | 黄色三级毛片 | 草逼网站| 亚洲精品视频网站在线观看 | 久久国产精品一区二区三区 | 中国一级特黄真人毛片 | 91视频在线 | 操操日| 一区二区三区亚洲 | 日本在线一区二区三区 | 成人免费网站视频 |