I am trying to figure out how to query a domain to find out where the default domain controllers OU via LDAP. I am consultant and do know that 99.9% of domains I will come across with have their the standard OU=domain controllers,DC=domain,DC=root. However, I'm trying to account for that .1% of admins that for what ever reason have moved it to like OU=why,OU=canteven,DC=domain,DC=root. I know that PowerShell can do this with Get-ADDomain but the tool my development team uses is Python. POSH will print a line like:
DomainControllersContainer : OU=Domain Controllers,DC=test,DC=lab
But again, the tools my developers are working on uses python so I'm stuck with traditional LDAP. Does anyone know where this is stored in AD? I just need the attribute path so I know where to point my Dev team. Thanks!
You might be better to utilize DNS for location of Domain Controllers. You might be able to use some of this information: https://ldapwiki.com/wiki/How%20Domain%20Controllers%20Are%20Located%20in%20Windows
As far as I know, there is no "default". The concept of "sites" is done from a ip segment condition.
You can also locate a lot of information about domain controllers via LDAP Queries.