So this was a fun little project at work that I started to help with my learning the ins and outs of Python. Theoretically, if your job titles and direct reports are kept up to date in Active Directory, you should be able to generate an organizational chart for any level of people. However, it’s more likely that it’s not which means it will show the discrepancies. This is what you will need, (in order):

You should get a chart like this (depending on the input parameters of course):

Pyinfo screenshot

In creating this script, I found the following resources useful:

The pydot docs aren’t as good as they could be as I only found a few examples and then the library documentation. I had to read the source code to get an idea about the acceptable attributes and available image formats.

The thing to realize though is that it’s just a wrapper around the graphviz executables. Pretty much everything doable in Graphviz can be done in pydot because it just passes the parameters through. Once I realised this, things got a lot easier because I could draw on the Graphviz documentation.

Here’s an example usage for the script:

> python -s ldap:// -u -p “your password” -r root.username -f output.png -i png