azure-ad-b2c - 如何根据自定义用户属性过滤 azure b2c 中的用户?
问题描述
我customerId
在 Azure B2C 用户属性中创建了自定义用户属性,以区分特定客户的用户。我可以使用Graph API和 .net B2C sdk 创建用户,并使用这个 git hub示例设置 customerId
我遇到的问题是我无法按 customerId 过滤客户。我的代码如下所示
public static async Task<List<User>> GetAllB2CUsersByCustomerId(GraphServiceClient graphClient, int customerId)
{
try
{
// Get users by customerId
var result = await graphClient.Users
.Request()
.Filter($"additionalData/any(c:c/key eq 'extension_b2cApplicationIdWithoutDashes_customerId' and c/value eq '{customerId}')")
.Select(e => new
{
e.DisplayName,
e.Id,
e.Identities
})
.GetAsync();
if (result != null)
{
return result.ToList();
}
}
catch (Exception ex)
{
// catch exception
}
return null;
}
当代码运行时出现以下异常
Code: BadRequest
Message: Filter not supported.
Inner error:
AdditionalData:
request-id: 21d0c9d3-7d6a-4c97-9066-c99f678aec54
date: 2020-06-10T15:59:37
ClientRequestId: 21d0c9d3-7d6a-4c97-9066-c99f678aec54
解决方案
只是如果它对某人有帮助,以下语法过滤器上的自定义属性
public static async Task<List<User>> GetAllB2CUsersByCustomerId(GraphServiceClient graphClient, int customerId)
{
try
{
// Get users by customerId
var result = await graphClient.Users
.Request()
.Filter($"extension_b2cApplicationIdWithoutDashes_customerId eq {customerId}")
.Select(e => new
{
e.DisplayName,
e.Id,
e.Identities
})
.GetAsync();
if (result != null)
{
return result.ToList();
}
}
catch (Exception ex)
{
// catch exception
}
return null;
}
推荐阅读
- python-3.x - 如何打开 VSC 网易音乐?
- jquery - 没有服务器代码的 Ajax 渲染部分视图
- docker - Docker 守护程序未运行
- r - ggplot geom_rect() 错误“找不到对象”
- java - 将项目导出为 jar 时删除 Jacoco 库依赖项
- spring-boot - 使用 Thymleaf 和 spring 遇到 org.springframework.web.method.annotation.MethodArgumentTypeMismatchException
- javascript - 使用 csv 文件中的链接使用 javascript 播放音频
- javascript - jVectorMap 获取点击区域的值
- spotfire - 为什么我的自定义 C# 扩展在部署到 Spotfire WebPlauer/Consumer 时不执行
- powershell - 无法处理参数,因为参数“名称”的值无效