Created
December 3, 2009 13:41
-
-
Save ekohl/248162 to your computer and use it in GitHub Desktop.
Retrieves all unique values of a specific LDAP attribute
This file contains 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
from ldap import initialize, SCOPE_SUBTREE | |
from operator import add | |
config = {'host': 'ldap://HOST', 'base': 'dc=example,dc=com', 'attr': 'l'} | |
result = initialize(config['host']).search_s(config['base'], SCOPE_SUBTREE, '(%s=*)' % config['attr'], [ config['attr'] ] ) | |
data = reduce(add, [ entry[config['attr']] for (dn, entry) in result ]) | |
print "\n".join(sorted(set(map(str.lower, data)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment