> ## Content Index
> Fetch the complete content index at: https://www.azurebrasil.cloud/llms.txt
> Use this file to discover other available public pages before exploring further.

# C# + Microsoft Graph = Lista de usuários inativos
- URL: https://www.azurebrasil.cloud/blog/c-microsoft-graph-lista-de-usuarios-inativos/
- Published: 2024-12-05T11:22:41.000Z
- Updated: 2024-12-05T11:22:40.000Z
- Author: Rafael dos Santos

Ola pessoALL,

Um dos nossos clientes pediu ajuda para montar um script que retornasse a lista de usuários que não fizeram login há mais de 90 dias no ambiente dele.  
Pensei comigo que seria coisa simples, montamos o script, testamos, tudo funcionando e, na hora de rodar pelo ambiente dele, absolutamente NADA do que tentamos funcionou.

> O Famoso, na minha máquina funciona!

Só que dessa vez era o "na minha máquina funciona" com powershell, esgotadas as tentativas, decidi fazer uma console app simples que exporta os dados necessários que o cliente precisa para um csv.  
O código final é bem simples e está no meu GitHub, mas quero aproveitar o post para explicar alguns conceitos de integração com as plataformas Microsoft.

[https://github.com/rsantosdev/aad-stale-users-csv](https://github.com/rsantosdev/aad-stale-users-csv?ref=azurebrasil.cloud)

[https://developer.microsoft.com/en-us/graph/graph-explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?ref=azurebrasil.cloud)

[https://graph.microsoft.com/v1.0/users?$select=userPrincipalName,displayName,mail,signInActivity&$filter=signInActivity/lastSignInDateTime+le+2024-10-01T00:00:00Z](https://graph.microsoft.com/v1.0/users?$select=userPrincipalName,displayName,mail,signInActivity&$filter=signInActivity/lastSignInDateTime+le+2024-10-01T00:00:00Z&ref=azurebrasil.cloud)  

[How to manage inactive user accounts - Microsoft Entra IDLearn how to detect and resolve Microsoft Entra user accounts that are inactive or obsolete using the Microsoft Entra admin center and Microsoft Graph.![](https://learn.microsoft.com/favicon.ico)Microsoft Learnshlipsey3![](https://learn.microsoft.com/en-us/media/open-graph-image.png)](https://learn.microsoft.com/en-us/entra/identity/monitoring-health/howto-manage-inactive-user-accounts?ref=azurebrasil.cloud)

[Create a Microsoft Graph client - Microsoft GraphDescribes how to create a client to use to make calls to Microsoft Graph. Includes how to set up authentication and select a sovereign cloud.![](https://learn.microsoft.com/favicon.ico)Microsoft LearnMIchaelMainer![](https://learn.microsoft.com/en-us/media/open-graph-image.png)](https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp&ref=azurebrasil.cloud)

[How do I resolve the error AADSTS7000218: The request body must contain the following parameter: ‘client\_secret’ or ‘client\_assertion’This is how I have written code and trying to get the output. The request body must contain the following parameter: client\_secret or client\_assertion static async Task&lt;AuthenticationResul…![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a)Stack Overflowravi rathod![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded)](https://stackoverflow.com/questions/45609432/how-do-i-resolve-the-error-aadsts7000218-the-request-body-must-contain-the-foll?ref=azurebrasil.cloud)