{"record":{"id":"0f7eb18e09a692bd","repo":"n8n-io/n8n","slug":"can-t-migrate-workflows-and-credentials-to-the-use","errorCode":null,"errorMessage":"Can't migrate workflows and credentials to the user with the ID ${flags.userId}. That user was created via LDAP and will be deleted as well.","messagePattern":"Can't migrate workflows and credentials to the user with the ID (.+?)\\. That user was created via LDAP and will be deleted as well\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/ldap/reset.ts","lineNumber":85,"sourceCode":"\t\t\tNumber(!!flags.deleteWorkflowsAndCredentials);\n\n\t\tif (numberOfOptions !== 1) {\n\t\t\tthrow new UserError(wrongFlagsError);\n\t\t}\n\n\t\tconst owner = await this.getOwner();\n\t\tconst ldapIdentities = await Container.get(AuthIdentityRepository).find({\n\t\t\twhere: { providerType: 'ldap' },\n\t\t\tselect: ['userId'],\n\t\t});\n\t\tconst personalProjectIds = await Container.get(\n\t\t\tProjectRelationRepository,\n\t\t).getPersonalProjectsForUsers(ldapIdentities.map((i) => i.userId));\n\n\t\t// Migrate all workflows and credentials to another project.\n\t\tif (flags.projectId ?? flags.userId) {\n\t\t\tif (flags.userId && ldapIdentities.some((i) => i.userId === flags.userId)) {\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`Can't migrate workflows and credentials to the user with the ID ${flags.userId}. That user was created via LDAP and will be deleted as well.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (flags.projectId && personalProjectIds.includes(flags.projectId)) {\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`Can't migrate workflows and credentials to the project with the ID ${flags.projectId}. That project is a personal project belonging to a user that was created via LDAP and will be deleted as well.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst project = await this.getProject(flags.userId, flags.projectId);\n\n\t\t\tawait Container.get(OwnershipTransferService).transferAllResources(\n\t\t\t\tpersonalProjectIds,\n\t\t\t\tproject.id,\n\t\t\t);\n\t\t}\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/ldap/reset.ts#L67-L103","documentation":"Thrown by `ldap:reset` when the operator passes `--userId` pointing at a user that was itself provisioned via LDAP. Because the command deletes every LDAP-managed user at the end of the run, transferring ownership to a user that is about to be deleted would orphan the workflows and credentials again. It is a UserError surfaced after the LDAP identity list is loaded.","triggerScenarios":"Passing `--userId=<ldap-user-id>` where that ID appears in `auth_identity` rows with `providerType: 'ldap'`. Common when an operator copies a user ID from the UI without checking how it was created.","commonSituations":"Migrating off LDAP and mistakenly targeting an LDAP user as the new owner; environments where every user was created through LDAP and no local owner candidate exists.","solutions":["Pick a user that was NOT created via LDAP (e.g. the instance owner) and pass its ID to `--userId`.","If no suitable local user exists, create or promote a local user first, then rerun the command.","Alternatively pass `--projectId` pointing at a shared/non-personal project, or use `--deleteWorkflowsAndCredentials`."],"exampleFix":"// before\nn8n ldap:reset --userId=<ldap-user-id>\n// after\nn8n ldap:reset --userId=<local-owner-id>","handlingStrategy":"validation","validationCode":"// Before running ldap:reset --userId=X, confirm X is NOT an LDAP user:\nconst ldapUserIds = (await authIdentityRepo.find({ where: { providerType: 'ldap' }, select: ['userId'] })).map(i => i.userId);\nif (ldapUserIds.includes(targetUserId)) {\n  throw new Error('Target user is LDAP-managed and will be deleted; pick a local user.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always target the instance owner or another local user as the migration destination.","Maintain a documented 'safe target user' per environment for LDAP resets."],"tags":["cli","ldap","ownership-transfer","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}