我正在尝试使用图形 API 构建一个请求,以启用所有在过去 30 天内未登录的用户。与:
$URL = "https://graph.microsoft.com/v1.0/users?`$filter=signInActivity/lastSignInDateTime le 2023-12-21T00:00:00Z"
我能够获取 2023 年 12 月 21 日之前未登录的所有用户。我需要进一步过滤列表以排除具有特定字段的用户,但它不起作用:
companyName ne 'mycompany' and department ne 'mydepartment' and accountEnabled eq true
$URL = "https://graph.microsoft.com/v1.0/users?`$filter=signInActivity/lastSignInDateTime le 2023-12-21T00:00:00Z and companyName ne 'mycompany' and department ne 'mydepartment' and accountEnabled eq true&`$select=userPrincipalName,signInActivity"
通过关注网址,我可以启用除我的公司和部门之外的所有用户。
$URL = "https://graph.microsoft.com/v1.0/users?`$count=true&`$top=999&ConsistencyLevel=eventual&`$filter=companyName ne 'mycompany' and department ne 'mydepartment' and accountEnabled eq true&`$select=userPrincipalName,signInActivity"
但不是过去 30 天内未登录的用户。我尝试添加:
$URL = "https://graph.microsoft.com/v1.0/users?`$count=true&`$top=999&ConsistencyLevel=eventual&`$filter=companyName ne 'mycompany' and department ne 'mydepartment' and accountEnabled eq true&`$select=userPrincipalName,signInActivity/lastSignInDateTime le 2023-12-21T00:00:00Z"
但它不起作用。有办法解决吗?
谢谢
如文档中所述,通过
signInActivity
进行过滤时,它不能与任何其他可过滤属性组合使用。
目前唯一的解决方案是在客户端应用
companyName
、department
和 accountEnabled
的过滤器。