1

Currently to get the parent OU of given OU is to strip the given OU dn and search again

parent_ou_dn_elements = ou_dn.split(',')[1:]
parent_ou_dn = ','.join(parent_ou_dn_elements)
ou_filter = '(& (objectclass=OrganizationalUnit)(distinguishedName={})'.format(parent_ou_dn)
ad_query(self.root_folder, ','.join(ou_filter))

Is there a more pythonic way to do so? eg.

ou.parent
James Lin
  • 25,028
  • 36
  • 133
  • 233

0 Answers0