none
Microsoft Graph API - User Query not working as expected RRS feed

  • Question

  • Hello,


    I want to construct a Graph API query to list users who have not logged on in the last 90 days, and then delete or suspend their accounts.


    Starting with this query:


    https://graph.microsoft.com/beta/users?filter=signInActivity/lastSignInDateTime le 2020-02-08T00:00:00Z&$select=displayName,createdDateTime,signInActivity


    The result.......


    With a sample set of  users, I am returned a list of 6 results in the following format:


    {
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users(displayName,createdDateTime,signInActivity)",
    "value": [
    {
    "id": "00283####################8119a7",
    "signInActivity": {
    "lastSignInDateTime": "2020-01-19T16:42:10Z",
    "lastSignInRequestId": "ac4ddfc1-45bc-4f00-9022-79de4e7b2a00"
    }
    },

    {......

    .......

    .......

    .....


    Followed by a list of 5 Users in the following format:


    {
    "id": "5a41d#######################72d7",
    "deletedDateTime": null,
    "accountEnabled": true,
    "ageGroup": null,

    .........

    .........

    .........

    .........

    "signInActivity": {
    "lastSignInDateTime": "2020-01-14T12:17:54Z",
    "lastSignInRequestId": "a0c2ee13-0ffa-4127-8a08-6cbd34a30e00"
    },

    ...............

    ..............

    ................

    ................

    },


    The 2 lists returned do not match - a list of 6 then a list of 5, plus the attributes don't match


    The first set of 6 must have been returnded by the select statement. However, in this instance:

    1. The User's DisplayName is not returned.
    2. The ID's returned do not match any of my User's ID's.
    3. And the lastSignInDateTime does not match any of the lastSignInDateTime of the Users listed in the following list of 5 Users

    Which list is correct, and that I can use to construct the Delete/Suspend query?


    Also why do I have 2 lists returned anyway - I only want the list returned by the summarised select statement. I must have constructed the query incorrectly. Can you help?


    Thanks in Advance

    Friday, May 8, 2020 2:46 PM