Detail oriented

Ed Fine's blog.

Graphviz Org Chart From LDAP

I wrote a simple Python utility, gen-orgchart, to pull down organizational information from an LDAP server and generate an org chart in Graphviz DOT format.

The org chart hierarchy is based on the manager LDAP attribute. Required LDAP attributes are, by supported schema:

inetOrgPerson Active Directory
departmentNumber department
displayName displayName
manager manager
o company
title title

The sections below summarize how to use this utility.

Usage

1
gen-orgchart [options] <ldapuri> <basedn>

Prerequisites

Comments

  • There’s no real attempt at a pretty layout, but it does the job.
  • It would be useful to be able to specify an LDAP filter. Currently, it includes everything under the base DN, which is not ideal if the directory is complex.
  • It’s useful to pipe the output to a renderer like xdot.
  • It’s only been tested on Debian/Ubuntu.

Examples

Getting help
1
gen-orgchart --help
Generate an org chart (long options)
1
2
3
4
5
6
# Generate an org chart from an Active Directory server at
# ldaps://ad.example.com, binding as me@example.com and prompting
# for a password.
gen-orgchart \
    --binddn me@example.com --askpass \
    ldaps://ad.example.com ou=people,dc=example,dc=com | xdot -
Generate an org chart (short options)
1
2
3
4
# As above, but with short options
gen-orgchart \
    -D me@example.com -W \
    ldaps://ad.example.com ou=people,dc=example,dc=com | xdot -