diff --git a/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py b/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py index 9a2ed9e..b78af2c 100644 --- a/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py +++ b/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py @@ -33,9 +33,11 @@ import copy import types import re +import sys import time import ldap import ipaddr +import traceback import univention.debug @@ -795,26 +797,27 @@ def _create(self): al.append( ( 'objectClass', [ 'univentionObject', ] ) ) al.append( ( 'univentionObjectType', [ self.module, ] ) ) - self.lo.add(self.dn, al) - - if hasattr(self,'_ldap_post_create'): - # if anything goes wrong we need to remove the already created object, otherwise we run into 'already exists' errors - try: + # if anything goes wrong we need to remove the already created object, otherwise we run into 'already exists' errors + try: + added = False + self.lo.add(self.dn, al) + added = True + if hasattr(self,'_ldap_post_create'): self._ldap_post_create() + except: + # ensure that there is no lock left + exc = sys.exc_info() + univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "Create operation failed: %s" % (traceback.format_exc(),)) + try: + self.cancel() except: - # ensure that there is no lock left - import traceback, sys - exc = sys.exc_info() - univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "Post-Create operation failed: %s" % (traceback.format_exc(),)) - try: - self.cancel() - except: - univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "Post-create: cancel() failed: %s" % (traceback.format_exc(),)) - try: + univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "create: cancel() failed: %s" % (traceback.format_exc(),)) + try: + if added: self.remove() - except: - univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "Post-create: remove() failed: %s" % (traceback.format_exc(),)) - raise exc[0], exc[1], exc[2] + except: + univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, "create: remove() failed: %s" % (traceback.format_exc(),)) + raise exc[0], exc[1], exc[2] self.call_udm_property_hook('hook_ldap_post_create', self)