n8n-io/n8n · error · UserError

Can't migrate workflows and credentials to the user with the

Error message

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.

What it means

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.

Source

Thrown at packages/cli/src/commands/ldap/reset.ts:85

			Number(!!flags.deleteWorkflowsAndCredentials);

		if (numberOfOptions !== 1) {
			throw new UserError(wrongFlagsError);
		}

		const owner = await this.getOwner();
		const ldapIdentities = await Container.get(AuthIdentityRepository).find({
			where: { providerType: 'ldap' },
			select: ['userId'],
		});
		const personalProjectIds = await Container.get(
			ProjectRelationRepository,
		).getPersonalProjectsForUsers(ldapIdentities.map((i) => i.userId));

		// Migrate all workflows and credentials to another project.
		if (flags.projectId ?? flags.userId) {
			if (flags.userId && ldapIdentities.some((i) => i.userId === flags.userId)) {
				throw new UserError(
					`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.`,
				);
			}

			if (flags.projectId && personalProjectIds.includes(flags.projectId)) {
				throw new UserError(
					`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.`,
				);
			}

			const project = await this.getProject(flags.userId, flags.projectId);

			await Container.get(OwnershipTransferService).transferAllResources(
				personalProjectIds,
				project.id,
			);
		}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Pick a user that was NOT created via LDAP (e.g. the instance owner) and pass its ID to `--userId`.
  2. If no suitable local user exists, create or promote a local user first, then rerun the command.
  3. Alternatively pass `--projectId` pointing at a shared/non-personal project, or use `--deleteWorkflowsAndCredentials`.

Example fix

// before
n8n ldap:reset --userId=<ldap-user-id>
// after
n8n ldap:reset --userId=<local-owner-id>
Defensive patterns

Strategy: validation

Validate before calling

// Before running ldap:reset --userId=X, confirm X is NOT an LDAP user:
const ldapUserIds = (await authIdentityRepo.find({ where: { providerType: 'ldap' }, select: ['userId'] })).map(i => i.userId);
if (ldapUserIds.includes(targetUserId)) {
  throw new Error('Target user is LDAP-managed and will be deleted; pick a local user.');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/0f7eb18e09a692bd. Report an issue: GitHub.