[services] Création et suppression des homes si modif de l'objectClass cransAccount, rattrapage d'une erreur si le service a redémarrer existe déjà
This commit is contained in:
parent
64a1d9f0ec
commit
dd94fcd228
1 changed files with 14 additions and 2 deletions
16
services.py
16
services.py
|
@ -138,7 +138,7 @@ def services_to_time_mail_bienvenue(x):
|
|||
if u'cransAccount' in [ str(o) for o in adh['objectClass']]:
|
||||
return [ NOW + 660 ]
|
||||
else:
|
||||
return [ 0 ]
|
||||
return [ NOW + 660 ]
|
||||
|
||||
# génération des arguments du service à redémarrer (par defaut [])
|
||||
services_to_args={}
|
||||
|
@ -302,7 +302,7 @@ def service_to_restart(conn, new=None, args=[], start=0):
|
|||
'start': start })
|
||||
try:
|
||||
conn.add_s(serv_dn, modlist)
|
||||
except ldap.ALREADY_EXISTS:
|
||||
except (ldap.ALREADY_EXISTS, ldap.TYPE_OR_VALUE_EXISTS):
|
||||
# Existe déja => rien à faire
|
||||
pass
|
||||
|
||||
|
@ -311,6 +311,18 @@ def services_to_restart(conn, old_attrs={}, new_attrs={}, created_object=[], del
|
|||
|
||||
update_now()
|
||||
|
||||
added_objectClass = [obc for obc in new_attrs.get("objectClass", []) if not obc in old_attrs.get("objectClass", [])]
|
||||
deleted_objectClass = [obc for obc in old_attrs.get("objectClass", []) if not obc in new_attrs.get("objectClass", [])]
|
||||
|
||||
# Je met la reconfiguration du home / del_user à la main pour la création/suppression d'un compte crans
|
||||
# parce que que je vois pas vraiement comment faire autrement
|
||||
if 'cransAccount' in added_objectClass:
|
||||
arg = services_to_args['home'](added_objectClass[0])
|
||||
service_to_restart(conn, "home", list(arg), 0)
|
||||
|
||||
if 'cransAccount' in deleted_objectClass:
|
||||
service_to_restart(conn, "del_user", ["%s,%s" % (old_attrs['uid'][0], old_attrs['homeDirectory'][0])], 0)
|
||||
|
||||
# On tranforme les dico *_attrs du type string -> attr en *_attrs_c du type class -> attr
|
||||
old_attrs_c = dict((attributs.AttributeFactory.get(key), value) for key,value in old_attrs.items() if attributs.AttributeFactory.get(key, fallback=None) != None and value)
|
||||
new_attrs_c = dict((attributs.AttributeFactory.get(key), value) for key,value in new_attrs.items() if attributs.AttributeFactory.get(key, fallback=None) != None and value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue