Unable to generate one-time auth code for LDAP user


I have a user that lost their two-factor authentication QR code and recovery codes and is locked out of Nextcloud.

They are an LDAP user, so their username is shown as a long string of letters and numbers. When I try to generate a one-time code, I enter the long username string this in to:

/index.php/settings/admin/security -->Two-Factor Admin–>Generate

and I get the error message:

Could not generate a code: unknown error

What am I doing wrong?

I have 2 factor admin support enabled in the web GUI.

When I try via the command line I get:

servername:/snap/nextcloud/current$ sudo -u www-data ./bin/occ twofactorauth:admin:generate-code 123AU777-XX11-8889-H888-H88888800001
[sudo] password for xxxxxxx:
./bin/occ: 4: .: Can’t open /utilities/mysql-utilities

The directory /snap/nextcloud/current/utilities/mysql-utilities does exist.

This is a Snap installation, so:

sudo nextcloud.occ twofactorauth:disable 123AU777-XX11-8889-H888-H88888800001 totp

worked fine and the user was able to log in and set up 2 factor again.