【问题标题】:Microsoft Graph API - generate the filter query for the extension attributeMicrosoft Graph API - 为扩展属性生成过滤器查询
【发布时间】:2021-01-09 15:53:41
【问题描述】:

我在 Azure AD B2C 中创建了一个名为 extensions_{b2cextensionappid}_IsDemoAccount 的扩展/自定义属性来标记用户是演示用户。

我尝试使用 dotnet 核心 API 中的 GraphServiceClient 创建筛选器查询以选择 Azure AD B2C 目录中的所有演示用户。但它不起作用。

   var result = await graphClient.Users
            .Request()
            //.Filter($"identities/any(c:c/issuerAssignedId eq 'test2' and c/issuer eq '{config.Value.TenantId}')")
            .Filter($"Extensions/any(c:c/{IsTemporaryAccount} eq true')")
            .Expand("Extensions")

有没有办法为扩展属性生成过滤查询?我在 Microsoft 文档中没有找到任何示例。

请提供任何解决方案或参考来实现这一目标?

【问题讨论】:

  • 您能解释一下您想要达到的目标吗?比如你正在执行的最终结果是什么。
  • @AbhishekAgrawal 模拟账户从创建之日起应该只有 5 天有效,我创建了一个服务来检查和删除过期的模拟账户。为此,我只需要从 AD 中查询模拟账户。我的广告有超过 50,000 个用户。
  • 嗨,你检查我的回答了吗?有用吗?

标签: microsoft-graph-api asp.net-core-webapi azure-ad-b2c graphserviceclient


【解决方案1】:

您混淆了Create extensionPropertyCreate open extension

extension_{b2cextensionappid}_IsDemoAccount 实际上是extensionProperty 而不是open extension

所以你应该使用下面的代码来过滤用户。

        var users = await graphClient.Users
        .Request()
        .Filter($"extension_{b2cextensionappid}_IsDemoAccount eq true")
        .GetAsync();

请注意扩展属性应为extension_**_** 而不是extensions_**_**

【讨论】:

    【解决方案2】:

    以下图表查询可帮助您根据自定义属性进行过滤。

    https://graph.microsoft.com/v1.0/users?$filter=extension_{b2cextensionappid}_IsDemoAccount eq 'Yes'&$select=extension_{b2cextensionappid}_IsDemoAccount

    你可以参考 Make API calls using the Microsoft Graph SDKs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多