diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index 661e9b15..72be2e9f 100644 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -1,19 +1,20 @@ -#!/bin/bash /usr/scripts/python.sh +#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) Frédéric Pauget # Licence : GPLv2 -import smtplib, socket, sys, commands, shutil, os, traceback,grp +import smtplib, sys, commands, shutil, os, traceback,grp from time import strftime - +sys.path.append('/usr/scripts/gestion') +if '/usr/scripts' not in sys.path: + sys.path.append('/usr/scripts') from gestion.affich_tools import cprint, anim, OK, WARNING, ERREUR import gestion.config as config import config.mails as config_mails import gestion.mail as mail_module - -from lc_ldap import shortcuts +from gestion.ldap_crans import hostname, crans_ldap try: sys.path.append('/usr/lib/mailman') @@ -24,12 +25,7 @@ except: # Machine sans mailman, les ML ne seront pas reconfigurées pass -# Connexion lc_ldap ro - -ldap = shortcuts.lc_ldap_readonly() - -# Hostname -hostname = socket.gethostname() +CONN = crans_ldap() class del_user: """ Suppression des fichiers d'un compte utilisateur """ @@ -121,17 +117,16 @@ class home: try: login, oldLogin, oldHome = args.split(",") if login: - res = ldap.search(u"uid=%s" % (login,))[0] - if res.ldap_name == u'adherent': - adh = res + res = CONN.search("login=%s" % (login,)) + if res['adherent']: + adh = res['adherent'][0] gid = config.gid elif res['club']: - adh = res + adh = res['club'][0] gid = config.club_gid - home = unicode(adh['homeDirectory'][0]) - uid = int(adh['uidNumber'][0]) - if adh['mailExt'] != []: - mail_redirect = unicode(adh['mailExt'][0]) + home = adh.home() + uid = adh.uidNumber() + mail_redirect = adh.email_exterieur() if oldHome and hostname == "zbee": home_service = del_user(["%s,%s" % (oldLogin, oldHome)]) home_service.delete_zbee()