Last active
January 10, 2018 18:15
-
-
Save heywoodlh/fd960a7803327470f24ae817cedd2e07 to your computer and use it in GitHub Desktop.
Print base dn for Active Directory domain using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| domain = 'ad.domain.org' | |
| bases = domain.split('.') | |
| bases_total = len(bases) | |
| global base_domain | |
| base_domain = '' | |
| run = 0 | |
| for base in bases: | |
| if run == 0: | |
| base_domain = 'dc=' + str(base) | |
| elif bases.index(base) == bases_total - 1: | |
| base_domain+='dc=' + str(base) | |
| else: | |
| base_domain+=',dc=' + str(base) + ',' | |
| run = run + 1 | |
| print('Base DN: ' + base_domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment