You must perform a search using an empty value for the base and then specifying in the filter the class of objects you want get back (or *
if you want all). You should use a single level scope to get only the first-level object in the ldap tree.
For example:
from ldap3 import Server, Connection, SEARCH_SCOPE_SINGLE_LEVEL
s = Server('your_server')
c = connection(s, user='your_user_dn', password='your_password', auto_bind=True)
c.search('', '(objectClass=*)', search_scope=SEARCH_SCOPE_SINGLE_LEVEL)
print(c.response)
you should get all the objects in the first level of the tree, if you want you can specify a filter with the object classes you need:
c.search('', '(!(objectClass=organization)(objectClass=organizationalUnit))', search_scope=SEARCH_SCOPE_SINGLE_LEVEL)