From 328904ae19ce4a75ae2868c8d0daa8346e2def09 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sun, 23 Feb 2014 17:22:39 +0100 Subject: [PATCH] [ldap_crans] ldap_crans ne modifie pas les host, hostAlias d'une machine ayant des certificats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C'est brûtal, mais je n'ai pas tu tout envie d'implémenter les certificat dans ldap_crans. On moins on peut toujours ajouter de nouveaux alias. De plus on interdit aussi la suppression d'une telle machine. --- gestion/gest_crans.py | 4 ++-- gestion/ldap_crans.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 1427fa02..5883b98a 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -933,7 +933,7 @@ def __prompt_input_menu(method, titre, prompt): else: method([num-1, val]) - except ValueError, c: + except (EnvironmentError, ValueError) as c: arg = u'--title "%s" ' % titre arg += u'--msgbox "%s\n\n\n" 0 0' % to_unicode(c.args[0]) dialog(arg) @@ -1135,7 +1135,7 @@ def confirm(clas): return 1 try: res = clas.save() - except RuntimeError, c: + except (EnvironmentError, RuntimeError) as c: arg = u'--title "Enregistrement" ' arg += u'--msgbox "%s\n\n\n" 0 0' % to_unicode(c.args[0]) dialog(arg) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index c1d9a768..3d521fc5 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -3008,6 +3008,9 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3) if type(new) == list: # Modif + res = self.conn.search_s(self.dn, 1, "xid=*") + if res: + raise EnvironmentError("La machine possède des certificats, utilisez lc_ldap ou l'intranet2") index = new[0] new = new[1] if new == '': @@ -3221,6 +3224,12 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3) ret = '' + # test si la machine a des certificats + if 'host' in self.modifs: + res = self.conn.search_s(self.dn, 1, "xid=*") + if res: + raise EnvironmentError("La machine possède des certificats, utilisez lc_ldap ou l'intranet2") + # Besoin de redémarrer les firewalls ? if 'ipHostNumber' in self.modifs or 'macAddress' in self.modifs: reconf_ip = self._init_data.get('ipHostNumber', []) @@ -3301,6 +3310,9 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3) if self.proprietaire().__class__ == AssociationCrans and not isadm(): raise EnvironmentError(u'Il faut être administrateur pour effectuer cette opération.') + res = self.conn.search_s(self.dn, 1, "xid=*") + if res: + raise EnvironmentError("La machine possède des certificats, utilisez lc_ldap ou l'intranet2") self.proprio = self.__proprietaire.Nom() # On met dans un coin le nom du proprio self.__proprietaire = None # On oublie le propriétaire