Search code examples
pythonactive-directoryldappython-ldap

Corresponding ldap query for "dsquery partition"


Is there a way I can find all partitions using a LDAP query? I have a parent domain and a number of child domains in my Active Directory. The global catalog is set on the child domain and I want to search all partitions on all parent as well as child domains in the Active directory from here.

Running "dsquery partition" on the child domain gives me the list but I am writing a Python program to get this. Currently I am using the following python-ldap method which gives me only the current child domain's partitions.

baseDNs = conn.search_s('', ldap.SCOPE_BASE,
                                '(objectClass=*)', ['namingContexts'])

What parameters should I pass to this method so that I can see all partitions?


Solution

  • Grab all the crossRef objects (objectClass=crossRef) in the CN=Partitions container of the forest's configuration naming context and you'll have what you need.