When querying the Microsoft Graph API for users, it’s not uncommon to encounter a large number of dummy or service accounts, especially in larger directories. To filter out these dummy users and retrieve only the relevant user data, you can use the $filter
query parameter to exclude accounts based on certain criteria, such as email patterns or account properties that are typical of real users.
For example, you could construct a query that excludes users with emails that match the dummy pattern you’ve mentioned. Here’s how you might structure your query to filter out users with email addresses that contain 'aab':
https://graph.microsoft.com/v1.0/users?$filter=not(startswith(mail, '_aab_'))
This uses the function to exclude any user whose email starts with 'aab'. You can adjust the startswith
filter to match the specific patterns of the dummy accounts in your domain.
Additionally, you might want to consider using other properties to filter users, such as accountEnabled, assignedLicenses, or other attributes that can help you distinguish between real and dummy accounts.
If you’re still facing issues or need more refined filtering, you might want to look into using the advanced query capabilities, which offers more complex filtering options.
Please ensure that you have the necessary permissions to perform these queries and that you’re following your organization’s data governance policies when accessing user data. If you need further assistance, feel free to ask!