Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Triggers
  • Resources
  • ABOUT ME
  • Get help with your flow
Menu

Check whether user exists in AAD with Power Automate

Posted on March 26, 2023March 26, 2023 by Tom

“I’d like to check whether a user with specific email address exists in our company’s Active Directory, can I use Power Automate to do that?”


When you’re working with email addresses, there’s always a difference whether it’s an internal or an external address. If it belongs to a user from your company, you can retrieve all his information from the Active Directory. On the other side, external email address is all you get, there’s no place to learn more about the user. But how do you check whether the user belongs to your company or not? Whether you can get this extra information?

Use ‘Run after’ after the ‘Get user profile’ action

If you know the user email address or his id, you can use the ‘Get user profile’ action. The small problem with this action is that it’ll fail for non-existing users.

But you can take it as a valid result (as when updating files) using the ‘Configure run after’ settings on the following actions.

Set the action to run after the ‘Get user profile’ has failed and define what to do when the user doesn’t exist.

Power Automate check user exists

Search for the user with an HTTP request

The second option, if you don’t want to deal with the ‘Run after’ settings, is to use an HTTP request. As explained in the previous article, you can search for a user using more properties than just his email or id. The HTTP request won’t fail for non-existing users, it’ll return either the user or an empty array.

Method: GET

Uri:
https://graph.microsoft.com/v1.0/users?$filter=<property> eq '<value>'

Check whether the output is empty (user doesn’t exist) or not (user exists), and continue accordingly.

empty(body('Send_an_HTTP_request')?['value'])
Power Automate check user exists

Summary

You’ve got two options how to check whether a user exists using Power Automate – a dedicated action or an http request. If you use the dedicated action, you’ll have all the information available as dynamic content, but you must use the not so common ‘run after’ settings. The HTTP request evaluation is simpler with a condition, on the other side you must extract the user information from the response JSON.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


There's also the HTTP requests to SharePoint cheat sheet to help you overcome limitations of some standard actions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with 1000s of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes