diff --git a/services/univention-ldb-modules/modules/univention_samaccountname_ldap_check.c b/services/univention-ldb-modules/modules/univention_samaccountname_ldap_check.c index 209a1e5..f1c66c5 100644 --- a/services/univention-ldb-modules/modules/univention_samaccountname_ldap_check.c +++ b/services/univention-ldb-modules/modules/univention_samaccountname_ldap_check.c @@ -282,15 +282,15 @@ static int univention_samaccountname_ldap_check_add(struct ldb_module *module, s if( ! WIFEXITED(status) ) { ldb_debug(ldb, LDB_DEBUG_ERROR, "%s: Cannot determine return status of ucs-school-create_windows_computer: %s (%d)\n", ldb_module_get_name(module), strerror(errno_wait), errno_wait); return LDB_ERR_UNWILLING_TO_PERFORM; - } else if( WEXITSTATUS(status) == 1 ) { - ldb_debug(ldb, LDB_DEBUG_ERROR, "%s: LDB_ERR_ENTRY_ALREADY_EXISTS\n", ldb_module_get_name(module)); - return LDB_ERR_ENTRY_ALREADY_EXISTS; } else if( WEXITSTATUS(status) == 2 ) { ldb_debug(ldb, LDB_DEBUG_ERROR, ("%s: ldb_add of machine object is disabled\n"), ldb_module_get_name(module)); return LDB_ERR_UNWILLING_TO_PERFORM; } else if( WEXITSTATUS(status) == 3 ) { ldb_debug(ldb, LDB_DEBUG_TRACE, ("%s: ldb_add of machine object ignored in dummy mode\n"), ldb_module_get_name(module)); return LDB_SUCCESS; + } else if( WEXITSTATUS(status) == 4 ) { + ldb_debug(ldb, LDB_DEBUG_ERROR, "%s: LDB_ERR_ENTRY_ALREADY_EXISTS\n", ldb_module_get_name(module)); + return LDB_ERR_ENTRY_ALREADY_EXISTS; } else if( WEXITSTATUS(status) ) { ldb_debug(ldb, LDB_DEBUG_ERROR, ("%s: unknown error code from ucs-school-create_windows_computer: %d\n"), ldb_module_get_name(module), WEXITSTATUS(status)); return LDB_ERR_UNWILLING_TO_PERFORM; diff --git a/services/univention-ldb-modules/ucs-school-create_windows_computer b/services/univention-ldb-modules/ucs-school-create_windows_computer index 8bbce98..db058d8 100755 --- a/services/univention-ldb-modules/ucs-school-create_windows_computer +++ b/services/univention-ldb-modules/ucs-school-create_windows_computer @@ -61,6 +61,7 @@ def main(): options['school'] = SchoolSearchBase.getOU(ucr.get('ldap/hostdn', '')) or SchoolSearchBase.getOU(ucr.get('dhcpd/ldap/base', '')) client = Client(args.server, args.username, args.password) result = client.umc_command(args.command, options).result + existed = result.get('existed') dn_ol = result.get('dn') if not dn_ol: # sys.exit(1) @@ -71,6 +72,8 @@ def main(): dn_s4 = dn_ol[:len(dn_ol) - len(ldap_base)] + samba4_ldap_base print dn_s4 + if existed: + sys.exit(4) if __name__ == '__main__': diff --git a/univention-management-console-module-selective-udm/umc/python/selective-udm/__init__.py b/univention-management-console-module-selective-udm/umc/python/selective-udm/__init__.py index d92500e..cdf928d 100644 --- a/univention-management-console-module-selective-udm/umc/python/selective-udm/__init__.py +++ b/univention-management-console-module-selective-udm/umc/python/selective-udm/__init__.py @@ -40,6 +40,7 @@ import univention.admin.modules import univention.admin.objects import univention.admin.uldap +import univention.admin.uexceptions import univention.admin.handlers.users.user import univention.admin.handlers.computers.windows @@ -121,5 +122,10 @@ def create_windows_computer(self, request, ldap_user_read=None, ldap_admin_write computer['password'] = password computer['description'] = request.options.get('description') - computer_dn = computer.create() - self.finished(request.id, {'dn': computer_dn}) + try: + computer_dn = computer.create() + existed = False + except univention.admin.uexceptions.objectExists as exc: + existed = True + computer_dn = exc.args[0] + self.finished(request.id, {'dn': computer_dn, 'existed': existed})