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