diff --git a/branches/ucs-3.2/ucs-3.2-1/base/univention-lib/python/ldap_extension.py b/branches/ucs-3.2/ucs-3.2-1/base/univention-lib/python/ldap_extension.py index 66974a9..f86c2dd 100644 --- a/branches/ucs-3.2/ucs-3.2-1/base/univention-lib/python/ldap_extension.py +++ b/branches/ucs-3.2/ucs-3.2-1/base/univention-lib/python/ldap_extension.py @@ -178,7 +178,7 @@ class UniventionLDAPExtension(object): appidentifier = os.environ.get('UNIVENTION_APP_IDENTIFIER') if appidentifier: cmd = ["univention-directory-manager", self.udm_module_name, "modify"] + self.udm_passthrough_options + [ - "--set", "appidentifier=%s" % (appidentifier,), + "--append", "appidentifier=%s" % (appidentifier,), "--dn", new_object_dn, ] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -272,24 +272,27 @@ class UniventionLDAPExtension(object): print >>sys.stderr, "ERROR: Object not found in UDM." return - app_filter = "" regex = re.compile('^ *appidentifier: (.*)$', re.M) - for appidentifier in regex.findall(stdout): - if appidentifier != "None": - app_filter = app_filter + "(cn=%s)" % appidentifier - + app_filter = [ + '(univentionAppID=%s)' % appId + for appId in regex.findall(stdout) + if appId != "None" + ] if app_filter: - cmd = ["univention-ldapsearch", "-xLLL", "(&(objectClass=univentionApp)%s)", "cn" % (app_filter,)] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - (stdout, stderr) = p.communicate() - if p.returncode: - print >>sys.stderr, "ERROR: LDAP search failed: %s" % (stdout,) - sys.exit(1) - if stdout: - regex = re.compile('^cn: (.*)$', re.M) - apps = ",".join(regex.findall(stdout)) - print >>sys.stderr, "INFO: The object %s is still registered by the following apps: %s" % (objectname, apps,) + filterstr = "(&(objectClass=univentionApp)(|%s))" % (''.join(app_filter),) + try: + lo, ldap_position = udm_uldap.getMachineConnection() + apps = ', '.join( + val[len('[en] '):] + for _dn, attrs in lo.search(filterstr, attr=['univentionAppDescription']) + for val in attrs['univentionAppDescription'] + if val.startswith('[en] ') + ) + print >> sys.stderr, "INFO: The object %s is still registered by the following apps: %s" % (objectname, apps,) sys.exit(2) + except udm_errors.base as ex: + print >> sys.stderr, "ERROR: LDAP search failed: %s" % (ex,) + sys.exit(1) cmd = ["univention-directory-manager", self.udm_module_name, "delete"] + self.udm_passthrough_options + [ "--dn", object_dn, @@ -376,7 +379,7 @@ class UniventionLDAPSchema(UniventionLDAPExtensionWithListenerHandler): if not rc > -1: ud.debug(ud.LISTENER, ud.WARN, '%s: New version is lower than version of old object (%s), skipping update.' % (name, old_version)) return - + try: new_object_data = bz2.decompress(new.get('univentionLDAPSchemaData')[0]) except TypeError: @@ -559,7 +562,7 @@ class UniventionLDAPACL(UniventionLDAPExtensionWithListenerHandler): if not rc > -1: ud.debug(ud.LISTENER, ud.WARN, '%s: New version is lower than version of old object (%s), skipping update.' % (name, old_version)) return - + try: new_object_data = bz2.decompress(new.get('univentionLDAPACLData')[0]) except TypeError: @@ -612,8 +615,6 @@ class UniventionLDAPACL(UniventionLDAPExtensionWithListenerHandler): backup_ucrinfo_filename = None os.close(backup_ucrinfo_fd) - - if not os.path.isdir(self.ucr_slapd_conf_subfile_dir): if os.path.exists(self.ucr_slapd_conf_subfile_dir): ud.debug(ud.LISTENER, ud.WARN, '%s: Directory name %s occupied, renaming blocking file.' % (name, self.ucr_slapd_conf_subfile_dir)) @@ -825,7 +826,7 @@ def option_validate_gnu_message_catalogfile(option, opt, value): raise OptionValueError("%s: file basename is not a registered language: %s" % (opt, value)) if not MIME_DESCRIPTION.file(value).startswith('GNU message catalog'): raise OptionValueError("%s: file is not a GNU message catalog: %s" % (opt, value)) - + return value class UCSOption (Option): @@ -911,7 +912,7 @@ def ucs_registerLDAPExtension(): # parser.add_option("-v", "--verbose", action="count") - + udm_passthrough_options = [] auth_options = OptionGroup(parser, "Authentication Options", "These options are usually passed e.g. from a calling joinscript") @@ -1024,7 +1025,7 @@ def ucs_unregisterLDAPExtension(): help="UDM hook", metavar="") # parser.add_option("-v", "--verbose", action="count") - + udm_passthrough_options = [] auth_options = OptionGroup(parser, "Authentication Options", "These options are usually passed e.g. from a calling joinscript")