web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Query Active Directory
Power Automate
Unanswered

Query Active Directory

(1) ShareShare
ReportReport
Posted on by

I loathe to hard code people's names into workflows, it just leads to heartache down the line.  How can I query active directory for the user account for a job title in Flow?  I'd really prefer to fire of an email from within a workflow to the Chief Executive Officer instead of coding Bill Lumbergh.

Categories:
I have the same question (0)
  • Community member Profile Picture
    on at

    Not directly possible today.

     

    But, if you are willing to go to the length of dabling around directly with APIs, you should be able to.  You need to call the following URL: https://graph.microsoft.com/v1.0/users?$filter=jobTitle eq 'CEO'

     

    You can write a custom API to do the job.  See here: https://powerapps.microsoft.com/en-us/tutorials/register-custom-api/

     

    You may also be able to achieve this using the HTTP+Swagger action as well.  See here: https://azure.microsoft.com/en-us/documentation/articles/connectors-native-http/#authentication

     

    Of course, I havent tried either... just preaching here.  Let know if that works for you.  Would love to know what worked for you.

  • jackst Profile Picture
    2 on at

    To query Active Directory for a user account based on job title, you can employ the Azure AD connector. This approach enables dynamic retrieval of user details based on specific attributes, such as job titles, without hardcoding names.

    Here's a streamlined process to achieve this:

    1. Use the Azure AD Connector: Power Automate provides the Azure AD connector that can be utilized to interact with Active Directory.
    2. Create a New Flow: In your Power Automate dashboard, start by creating a new flow. Opt for an automated flow if you need it to trigger based on certain events.
    3. Add the 'Get User' or 'Search for Users (V2)' Action: In your flow, add the 'Get User' action if you know the unique identifier of the user. However, since you want to search based on job titles, it’s more efficient to use the 'Search for Users (V2)' action. This action allows you to specify a search query.
    4. Configure the Search Query: In the 'Search for Users (V2)' action, you can specify a query to filter users based on their job titles. For example, you can use a query like jobTitle eq 'Chief Executive Officer'. This will return users whose job title matches 'Chief Executive Officer'.
    5. Process the Results: Once you have the search results, you can process them as needed. For instance, you can extract the user's email address and use it in a subsequent 'Send an Email' action. This way, the email will be dynamically sent to the user holding the specified job title at the time the workflow is executed.
    6. Error Handling: Implement error handling to manage scenarios where no user is found or multiple users have the same job title.
    7. Test Your Flow: Thoroughly test the flow to ensure it behaves as expected in different scenarios, such as when job titles change or new users are added.

     

    I hope that works for you!

    Jack from Emerge Digital

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard