All pastes #1362244 Raw Edit

All unique values of an LDAP att

public python v1 · immutable
#1362244 ·published 2009-03-16 14:16 UTC
rendered paste body
import ldapfrom sets import Setconfig = {'host': 'ldap://ldap.example.com', 'base': 'ou=People,dc=example,dc=com', 'attr': 'l'}data = Set()result = ldap.initialize(config['host']).search_s(config['base'], ldap.SCOPE_SUBTREE, '(%s=*)' % config['attr'], [ config['attr'] ] )for dn, entry in result:        for l in entry['l']:                data.add(l)for i in sorted(data):        print i