2017-06-06 165 views
0

我試圖複製下面的示例https://github.com/Azure-Samples/active-directory-dotnet-windows-store(一個Windows商店應用程序對azure AD進行身份驗證),但我用Azure函數替換Web應用程序。Windows商店應用程序進行天藍色功能驗證

在功能,代碼檢查用戶是否登錄如下:

ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope").Value.Contains("user_impersonation")) 

但這並不包含所需的值,以及其他調用不返回任何值,或者(如ClaimsPrincipal .Current.FindFirst(ClaimTypes.GivenName));

你知道發生了什麼嗎?

回答

0

它與代碼是否在Web App或Azure Function中運行無關。根本原因是您獲取令牌的差異參數/方式。

當您使用Azure AD保護Azure功能並將該令牌與請求相關聯時,它還會解析該令牌並讀取令牌中的聲明並構造ClaimsPrincipal對象。

您可以在this site中解析令牌以檢查令牌中您期望的聲明。