whos_lc.py 737 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash /usr/scripts/python.sh
# -*- mode: python; coding: utf-8 -*-
import sys
from affich_tools import coul, prompt
import lc_ldap.shortcuts
import lc_ldap.printing
import lc_ldap.filter2 as filter

if __name__ == '__main__':
    if len(sys.argv) >1:
        conn=lc_ldap.shortcuts.lc_ldap_admin()
12
        result=conn.search(filter.human_to_ldap(sys.argv[1].decode('utf-8')), sizelimit=4000)
13 14 15 16 17 18 19 20 21 22
        if not result:
            print "rien trouvé"
        else:
            if len(result) == 1:
                result[0].display()
            else:
                print lc_ldap.printing.sprint_list(result)
                print "%s résultats" % len(result)
    else:
        sys.stderr.write("Usage: %s {filtre}" % sys.argv[0])