diff --git a/management/univention-management-console-module-udm/umc/python/udm/__init__.py b/management/univention-management-console-module-udm/umc/python/udm/__init__.py index 75b4b52..c70ee92 100644 --- a/management/univention-management-console-module-udm/umc/python/udm/__init__.py +++ b/management/univention-management-console-module-udm/umc/python/udm/__init__.py @@ -267,7 +267,8 @@ def license_info(self, request, ldap_connection=None, ldap_position=None): self.finished(request.id, license_data) - def license_import(self, request): + @LDAP_Connection + def license_import(self, request, ldap_connection=None, ldap_position=None): filename = None if isinstance(request.options, (list, tuple)) and request.options: # file upload @@ -298,7 +299,7 @@ def _error(msg=None): # check license and write it to LDAP importer = LicenseImport(fd) importer.check(ucr.get('ldap/base', '')) - importer.write(self._user_dn, self._password) + importer.write(ldap_connection) except (ValueError, AttributeError, LDAPError) as exc: MODULE.error('License import failed (malformed LDIF): %r' % (exc, )) # AttributeError: missing univentionLicenseBaseDN diff --git a/management/univention-management-console-module-udm/umc/python/udm/tools.py b/management/univention-management-console-module-udm/umc/python/udm/tools.py index 5f03553..3f99e1e 100644 --- a/management/univention-management-console-module-udm/umc/python/udm/tools.py +++ b/management/univention-management-console-module-udm/umc/python/udm/tools.py @@ -103,15 +103,13 @@ def handle(self, dn, entry): # for atr in entry: # self.mod_list.insert( 0, ( ldap.MOD_REPLACE, atr, entry[ atr ] ) ) - def write(self, user_dn, passwd): - ldap_con = ldap.open("localhost", port=int(ucr.get('ldap/server/port', 7389))) - ldap_con.simple_bind_s(user_dn, passwd) + def write(self, ldap_connection): + ldap_con = ldap_connection.lo.lo try: ldap_con.add_s(self.dn, self.addlist) except ldap.ALREADY_EXISTS: ldap_con.delete_s(self.dn) ldap_con.add_s(self.dn, self.addlist) - ldap_con.unbind_s() def check_license(ldap_connection, ignore_core_edition=False):