scripts/sip/user_exist.py

24 lines
534 B
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('/usr/scripts/gestion')
sys.path.append('/usr/scripts/')
sys.path.append('/etc/crans/secrets/')
import secrets
import lc_ldap.shortcuts
conn=lc_ldap.shortcuts.lc_ldap_admin()
try:
if len(sys.argv[1])==5:
aid=int(sys.argv[1][1:])
else:
raise ValueError('Pas un numero valide')
except ValueError:
sys.stdout.write('FALSE')
exit(0)
if conn.search(u"aid=%s" % aid):
sys.stdout.write('TRUE')
else:
sys.stdout.write('FALSE')