From b14847c62533397b53fb2bb8c71f1863d285a7cd Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 21 Oct 2015 23:35:27 +0200 Subject: [PATCH] Adherent.py sous lc_ldap --- gestion/gen_confs/adherents.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index 72be2e9f..661e9b15 100644 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -1,20 +1,19 @@ -#! /usr/bin/env python +#!/bin/bash /usr/scripts/python.sh # -*- coding: utf-8 -*- # Copyright (C) Frédéric Pauget # Licence : GPLv2 -import smtplib, sys, commands, shutil, os, traceback,grp +import smtplib, socket, 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 gestion.ldap_crans import hostname, crans_ldap + +from lc_ldap import shortcuts try: sys.path.append('/usr/lib/mailman') @@ -25,7 +24,12 @@ except: # Machine sans mailman, les ML ne seront pas reconfigurées pass -CONN = crans_ldap() +# Connexion lc_ldap ro + +ldap = shortcuts.lc_ldap_readonly() + +# Hostname +hostname = socket.gethostname() class del_user: """ Suppression des fichiers d'un compte utilisateur """ @@ -117,16 +121,17 @@ class home: try: login, oldLogin, oldHome = args.split(",") if login: - res = CONN.search("login=%s" % (login,)) - if res['adherent']: - adh = res['adherent'][0] + res = ldap.search(u"uid=%s" % (login,))[0] + if res.ldap_name == u'adherent': + adh = res gid = config.gid elif res['club']: - adh = res['club'][0] + adh = res gid = config.club_gid - home = adh.home() - uid = adh.uidNumber() - mail_redirect = adh.email_exterieur() + home = unicode(adh['homeDirectory'][0]) + uid = int(adh['uidNumber'][0]) + if adh['mailExt'] != []: + mail_redirect = unicode(adh['mailExt'][0]) if oldHome and hostname == "zbee": home_service = del_user(["%s,%s" % (oldLogin, oldHome)]) home_service.delete_zbee()