string date = DateTime.Today.AddDays(-30).ToString("yyyy-MM-ddTHH-mm-ssZ");
var users = await client.Users
.Request()
.Filter($"signInActivity/lastSignInDateTime le {date}")
.GetAsync();
這會回傳無效過濾器子句錯誤,但似乎與此處詳述的過濾器匹配:
https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-beta&tabs=http#example-5-list-the-last-sign-in-time-of-特定時間范圍內的用戶
我檢查了訊息,似乎也匹配。我錯過了什么?
uj5u.com熱心網友回復:
我在Microsoft Graph Explorer 中嘗試了這兩個請求:
https://graph.microsoft.com/beta/users?$filter=signInActivity/lastSignInDateTime le 2021-07-21T00-00-00Z
回傳一個Invalid filter clause. 此請求使用您的日期格式。
https://graph.microsoft.com/beta/users?$filter=signInActivity/lastSignInDateTime le 2021-07-21T00:00:00Z
它回傳Calling principal does not have required MSGraph permissions AuditLog.Read.All但這是正常的,因為我沒有經過身份驗證并使用了來自 Microsoft 的示例實體。我認為您的實體不會出現此錯誤。這個想法是過濾器在這里似乎是正確的。
問題似乎出在您的格式上,您應該嘗試ToString("yyyy-MM-ddTHH:mm:ssZ")而不是ToString("yyyy-MM-ddTHH-mm-ssZ").
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/351637.html
