ldap3
ldap3 copied to clipboard
No objects found within the specified OU
Hi. I'm trying to collect objects in our Active Directory, but I'm getting the same error all the time no matter what. "No objects found within the specified OU."
I have tried to change the ou_path, but no luck. So I wounder if what I have done, is the right approach?
My code is this:
from ldap3 import Server, Connection, SUBTREE
server_uri = 'ldap://ad.company.org'
ou_path = 'OU=Users,OU=SO,OU=DK,OU=Company,DC=ad,DC=company,DC=org'
ldap_query = f'(objectClass=*)'
server = Server(server_uri)
conn = Connection(server)
conn.bind()
conn.search(search_base=ou_path, search_filter=ldap_query, search_scope=SUBTREE)
if conn.entries:
for entry in conn.entries:
print(entry.entry_dn)
else:
print("No objects found within the specified OU.")
conn.unbind()
Did you solve this? It seems that you do not have permission to read the objects.
I have this same issue. There are times I am searching for an email and ldap3 returns no entries but the email exists in AD. I ran a loop a hundred times to search for an email and got inconsistent results. 5 out of 100 returned zero entries.