# Locate objects in Active Directory

**URL:** <https://forum.ansible.com/t/locate-objects-in-active-directory/37066>\
**Category:** Ansible Project\
**Created:** [September 5, 2022, 6:49pm UTC](https://forum.ansible.com/t/locate-objects-in-active-directory/37066 "2022-09-05T18:49:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sagan](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sagan](https://forum.ansible.com/u/Sagan)\
**Post date:** [September 5, 2022, 6:49pm UTC](https://forum.ansible.com/t/locate-objects-in-active-directory/37066/1 "2022-09-05T18:49:53Z")

</div>

Greetings,

I’m having a bit of a tool gap because I can’t quite figure out where to go here… here’s what I want to do.

I have a list with the OU names, very straightforward. And what I need to do is, use that list to find all the users that are in those UOs. Now here’s the issue, the AD is very big and I have pinned down where all the users I need are but there are still a lot of branches and I can’t tell where they are.

Is there a way that ansible can locate these UOs?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [September 6, 2022, 12:56am UTC](https://forum.ansible.com/t/locate-objects-in-active-directory/37066/2 "2022-09-06T00:56:22Z")

</div>

> Greetings,
> 
> I’m having a bit of a tool gap because I can’t quite figure out where to go here… here’s what I want to do.
> 
> I have a list with the OU names, very straightforward. And what I need to do is, use that list to find all the users that are in those UOs. Now here’s the issue, the AD is very big and I have pinned down where all the users I need are but there are still a lot of branches and I can’t tell where they are.
> 
> Is there a way that ansible can locate these UOs?

No. You need to tune the exact ldap query that will get the desired results (for instance with ldapquery) and then you can use  
[https://docs.ansible.com/ansible/latest/collections/community/general/ldap\_search\_module.html](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_search_module.html) to use that in ansible.
