Occ user:delete is not deleting data folder of remnant LDAP user

Nextcloud version: 26.0.3
Operating system and version: AlmaLinux release 8.8 (Sapphire Caracal)
Apache version: Apache/2.4.37 (AlmaLinux)
PHP version: 8.1.20

I noticed that removing deleted ldap users with occ user:delete does not remove their data folder.
I recently updated to 26.0.3 but it could be a problem for a while, I only use occ from time to time.

Here is the error I am facing:
sudo -u apache php occ user:delete “FF6174A3-2E12-410C-8FDA-4572B598A02F”

In UserDeletedFilesCleanupListener.php line 58:
User has no home storage
user:delete

The folder exists, but is empty (the user likely never logged in):
drwxr-xr-x. 2 apache apache 6 Jun 26 17:53 FF6174A3-2E12-410C-8FDA-4572B598A02F

Is this the first time you’ve seen this error? Yes

Steps to replicate it:

  1. sudo -u apache php occ ldap:show-remnants
  2. sudo -u apache php occ user:delete “IDofuser”

It’s repeatable with every remnant LDAP user.

The output of your Nextcloud log in Admin > Logging:
OC\User\NoUserException: FF6174A3-2E12-410C-8FDA-4572B598A02F is not a valid user anymore

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):
$CONFIG = array (
‘instanceid’ => ‘xyz’,
‘passwordsalt’ => ‘xyz’,
‘secret’ => ‘xyz’,
‘trusted_domains’ =>
array (
0 => ‘xyz’,
1 => ‘xyz’,
),
‘datadirectory’ => ‘/var/www/html/nextcloud/data’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘26.0.3.2’,
‘overwrite.cli.url’ => ‘https://xyz’,
‘htaccess.RewriteBase’ => ‘/’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘mysql.utf8mb4’ => true,
‘dbuser’ => ‘nextcloud’,
‘dbpassword’ => ‘xyz’,
‘installed’ => true,
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtphost’ => ‘xyz’,
‘mail_sendmailmode’ => ‘smtp’,
‘mail_smtpport’ => ‘25’,
‘mail_from_address’ => ‘xyz’,
‘mail_domain’ => ‘xyz’,
‘lost_password_link’ => ‘xyz’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘memcache.distributed’ => ‘\OC\Memcache\Redis’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/run/redis/redis-server.sock’,
‘port’ => 0,
‘timeout’ => 1.5,
),
‘ldapIgnoreNamingRules’ => false,
‘ldapProviderFactory’ => ‘OCA\User_LDAP\LDAPProviderFactory’,
‘default_language’ => ‘de’,
‘default_locale’ => ‘de_DE’,
‘default_phone_region’ => ‘DE’,
‘enable_previews’ => ‘false’,
‘ldapUserCleanupInterval’ => ‘240’,
‘maintenance’ => false,
‘theme’ => ‘’,
‘loglevel’ => 2,
‘updater.release.channel’ => ‘stable’,
‘skeletondirectory’ => ‘/var/www/html/emptyskeleton/’,
‘twofactor_enforced’ => ‘true’,
‘twofactor_enforced_groups’ =>
array (
),
‘twofactor_enforced_excluded_groups’ =>
array (
0 => ‘local’,
),
‘updater.secret’ => ‘xyz’,
);

The output of your Apache/nginx/system log in /var/log/____:
nothing in the error log

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors.
{“file”:“/var/www/html/nextcloud/occ”,“line”:11,“args”:[“/var/www/html/nextcloud/console.php”],“function”:“require_once”}],“File”:“/var/www/html/nextcloud/apps/user_ldap/lib/User_LDAP.php”,“Line”:455,“message”:“FF6174A3-2E12-410C-8FDA-4572B598A02F is not a valid user anymore”,“exception”:{},“CustomMessage”:“FF6174A3-2E12-410C-8FDA-4572B598A02F is not a valid user anymore”}}

I can add the full line if necessary :slight_smile:

It seems to remove the user after a while, so user:delete will then show “User does not exist”, but still the data folder exists.

Regards,
Pascal

Sounds a little like server#28791, but that was supposedly fixed awhile ago. Even so, does it make any difference if you make the change either from the web UI or the OCS API instead of via occ?

yea, I found that aswell and it seems fixed since 23.0.3, but I am on 26.0.3

I wasn’t able to make the OCS API work to be honest :slight_smile:
I am investigating further and it seems that the update from 26.0.2 to 26.0.3 messed it up. I restored a previous backup and currently doing some tests with it

will keep this thread updated, can I pause it somehow?

I backtracked the issue and it appears since we changed our LDAP integration (it was a couple days before the update).
First we used a very basic Base DN, but now wanted to exclude some OU’s.

Example:
OU=NC Users,DC=nc,DC=local

Changed to:
OU=1,OU=NC Users,DC=nc,DC=local
OU=2,OU=NC Users,DC=nc,DC=local

Users which would now be on different OU’s and therefore excluded, can’t be removed with occ delete:user and suffer from this error.
It’s may due the fact that the user wasn’t actually removed within the AD, but the error makes no sense to me.

I am still investigating further :slight_smile:

Regards,
Pascal