【问题标题】:ADAL query security groupsADAL 查询安全组
【发布时间】:2018-04-25 17:59:20
【问题描述】:

我有一个通过 azure 上的 web api 登录到原生 wpf 应用程序的系统。

AuthenticationContext authContext = new AuthenticationContext(string.Format("https://login.windows.net/{0}", authority));
AuthenticationResult tokenAuthResult = authContext.AcquireTokenAsync(resource, clientId, new Uri(redirectUri), new PlatformParameters(PromptBehavior.Auto)).Result;

if (tokenAuthResult == null) return;          

Credentials.RestCredentials = new TokenCredentials(tokenAuthResult.AccessToken);

Credentials.UserName = string.Concat(tokenAuthResult.UserInfo.GivenName, " ", tokenAuthResult.UserInfo.FamilyName);

这一切都很完美,返回令牌等。 用户都在 ADAL 中,并且有针对他们的关联组(这些都是 O365 用户)。 我希望能够查询登录用户关联的组是什么。 我需要使用 Graph api 进行新的调用吗? 我是否使用返回的令牌? 我在这里有点迷路了。 提前致谢 斯科特

【问题讨论】:

    标签: c# rest azure-active-directory adal


    【解决方案1】:

    添加到@juunas 的答案,以下示例active-directory-dotnet-webapp-groupclaims 详细解释了事情。

    特别是Step 3: Configure your application to receive group claims 解释了清单中的应用配置。

    另请参阅https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-token-and-claims#claims-in-idtokens中与群组相关的声明

    【讨论】:

      【解决方案2】:

      一种简单的方法是在 Azure AD 中注册您的应用,单击 Manifest,然后修改 groupMembershipClaims 属性:

      "groupMembershipClaims": "SecurityGroup",
      

      这将产生包含用户组 ID 的 Id 令牌。 但是它确实有一个限制,只能包含一定数量的组,在这种情况下,您必须改为从 Graph API 获取它们。

      这是您在这种情况下需要调用的端点:https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/functions-and-actions#getMemberGroups

      【讨论】:

      • 谢谢。我实际上已经设置了这个,但是当我检查令牌并返回用户信息时没有看到任何进一步的信息。我错过了什么吗?我添加了所有图形权限 afaik。再次感谢。
      • 我明天工作时会在此处发布屏幕截图,如果可能的话。
      • 出现的唯一选项是; AccessToken AccessTokenType Authority ExpiresOn ExtendedLifeTimeToken IdToken TenantId UserInfo
      • IdToken 仅包含外观上的不记名令牌
      • 您是否尝试过反序列化 id 令牌,例如jwt.ms?它应该包含组 ID。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多