Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Can't delete ldap users #34557

Closed
6 of 9 tasks
Bevito opened this issue Oct 12, 2022 · 6 comments · Fixed by #37346
Closed
6 of 9 tasks

[Bug]: Can't delete ldap users #34557

Bevito opened this issue Oct 12, 2022 · 6 comments · Fixed by #37346
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@Bevito
Copy link

Bevito commented Oct 12, 2022

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Hi,

I can't delete users that are not in LDAP anymore.
The command 'php occ user:delete id-account' return a PHP error.

I think this worked in previous Nextcloud version 24.x
I've updated Nextcloud server from 24.0.5 to 24.0.6 on thursday the 6th of october (the updates worked like a charm : no errors reported)

Feel free to ask if you need any others informations.

Thanks a lot for your help and your time.

Steps to reproduce

  1. Connect to Nextcloud server
  2. Used the command ''sudo -u www-data php occ ldap:show-remnants"
    => The command works
  3. Used the command "sudo -u www-data php occ user:delete id-return-by-previous-command"
    => The command return :
 An unhandled exception has been thrown:
Error: Call to undefined method OCA\User_LDAP\User\OfflineUser::getExtStorageHome() in /var/www/html/nextcloud/apps/user_ldap/lib/Handler/ExtStorageConfigHandler.php:65
Stack trace:
#0 /var/www/html/nextcloud/apps/files_external/lib/MountConfig.php(100): OCA\User_LDAP\Handler\ExtStorageConfigHandler->handle()
#1 /var/www/html/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php(76): OCA\Files_External\MountConfig::substitutePlaceholdersInConfig()
#2 /var/www/html/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php(124): OCA\Files_External\Config\ConfigAdapter->prepareStorageConfig()
#3 [internal function]: OCA\Files_External\Config\ConfigAdapter->OCA\Files_External\Config\{closure}()
#4 /var/www/html/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php(122): array_map()
#5 /var/www/html/nextcloud/lib/private/Files/Config/MountProviderCollection.php(124): OCA\Files_External\Config\ConfigAdapter->getMountsForUser()
#6 /var/www/html/nextcloud/lib/private/Files/SetupManager.php(225): OC\Files\Config\MountProviderCollection->addMountForUser()
#7 /var/www/html/nextcloud/lib/private/Files/SetupManager.php(317): OC\Files\SetupManager->OC\Files\{closure}()
#8 /var/www/html/nextcloud/lib/private/Files/SetupManager.php(226): OC\Files\SetupManager->setupForUserWith()
#9 /var/www/html/nextcloud/lib/private/Files/SetupManager.php(388): OC\Files\SetupManager->setupForUser()
#10 /var/www/html/nextcloud/lib/private/Files/Mount/Manager.php(95): OC\Files\SetupManager->setupForPath()
#11 /var/www/html/nextcloud/lib/private/Files/Filesystem.php(320): OC\Files\Mount\Manager->find()
#12 /var/www/html/nextcloud/lib/private/Files/View.php(1162): OC\Files\Filesystem::resolvePath()
#13 /var/www/html/nextcloud/lib/private/Files/View.php(384): OC\Files\View->basicOperation()
#14 /var/www/html/nextcloud/apps/onlyoffice/lib/fileversions.php(93): OC\Files\View->is_dir()
#15 /var/www/html/nextcloud/apps/onlyoffice/lib/fileversions.php(116): OCA\Onlyoffice\FileVersions::checkFolderExist()
#16 /var/www/html/nextcloud/apps/onlyoffice/lib/fileversions.php(305): OCA\Onlyoffice\FileVersions::getView()
#17 /var/www/html/nextcloud/apps/onlyoffice/lib/hooks.php(72): OCA\Onlyoffice\FileVersions::deleteAllVersions()
#18 /var/www/html/nextcloud/lib/private/legacy/OC_Hook.php(106): OCA\Onlyoffice\Hooks::userDelete()
#19 /var/www/html/nextcloud/lib/private/Server.php(576): OC_Hook::emit()
#20 [internal function]: OC\Server->OC\{closure}()
#21 /var/www/html/nextcloud/lib/private/Hooks/EmitterTrait.php(106): call_user_func_array()
#22 /var/www/html/nextcloud/lib/private/Hooks/PublicEmitter.php(40): OC\Hooks\BasicEmitter->emit()
#23 /var/www/html/nextcloud/lib/private/User/User.php(259): OC\Hooks\PublicEmitter->emit()
#24 /var/www/html/nextcloud/core/Command/User/Delete.php(65): OC\User\User->delete()
#25 /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\User\Delete->execute()
#26 /var/www/html/nextcloud/core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run()
#27 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(1009): OC\Core\Command\Base->run()
#28 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#29 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#30 /var/www/html/nextcloud/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
#31 /var/www/html/nextcloud/console.php(100): OC\Console\Application->run()
#32 /var/www/html/nextcloud/occ(11): require_once('/var/www/html/n...')
#33 {main}Delete user: 08fc41c8-5bdb-103c-842a-7b63e5945167

Expected behavior

The command 'sudo -u www-data php occ user:delete id-return-by-previous-command' should worked.

Installation method

Community Web installer on a VPS or web space

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated from a minor version (ex. 22.2.3 to 22.2.4)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "24.0.6.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "maxZipInputSize": 1073741824,
        "allowZipDownload": true,
        "theme": "",
        "overwrite.cli.url": "https:\/\/cloud.iut-orsay.fr",
        "htaccess.RewriteBase": "\/",
        "maintenance": false,
        "default_language": "fr",
        "default_phone_region": "FR",
        "defaultapp": "files,dashboard",
        "log_type": "owncloud",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "loglevel": 0,
        "trusted_domains": [
            "cloud.iut-orsay.fr"
        ],
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trashbin_retention_obligation": "15, auto",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "dbindex": 0,
            "timeout": 0
        },
        "onlyoffice": {
            "jwt_secret": "LEiBy5rh6qdk",
            "jwt_header": "AuthorizationJwt"
        },
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "ldapUserCleanupInterval": "60",
        "updater.release.channel": "stable",
        "mysql.utf8mb4": true,
        "mail_sendmailmode": "smtp",
        "app_install_overwrite": [
            "printer"
        ]
    }
}

List of activated Apps

Enabled:
  - accessibility: 1.10.0
  - activity: 2.16.0
  - admin_audit: 1.14.0
  - bruteforcesettings: 2.4.0
  - circles: 24.0.1
  - cloud_federation_api: 1.7.0
  - comments: 1.14.0
  - contactsinteraction: 1.5.0
  - dashboard: 7.4.0
  - dav: 1.22.0
  - drawio: 1.0.3
  - federatedfilesharing: 1.14.0
  - federation: 1.14.0
  - files: 1.19.0
  - files_external: 1.16.1
  - files_pdfviewer: 2.5.0
  - files_rightclick: 1.3.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_versions: 1.17.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - nextcloud_announcements: 1.13.0
  - notifications: 2.12.1
  - oauth2: 1.12.0
  - onlyoffice: 7.5.4
  - password_policy: 1.14.0
  - photos: 1.6.0
  - privacy: 1.8.0
  - provisioning_api: 1.14.0
  - recommendations: 1.3.0
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - sharebymail: 1.14.0
  - support: 1.7.0
  - survey_client: 1.12.0
  - systemtags: 1.14.0
  - tasks: 0.14.4
  - text: 3.5.1
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - updatenotification: 1.14.0
  - user_ldap: 1.14.1
  - user_status: 1.4.0
  - viewer: 1.8.0
  - weather_status: 1.4.0
  - workflowengine: 2.6.0
Disabled:
  - announcementcenter: 6.3.1
  - encryption
  - groupfolders: 12.0.1
  - quota_warning: 1.14.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No response

Additional info

No response

@Bevito Bevito added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Oct 12, 2022
@AndyXheli
Copy link

Try one of thr below options works for me with no issues 

Option 1

sudo -u www-data php /var/www/nextcloud/occ ldap:show-remnants

sudo -u www-data php /var/www/nextcloud/occ user:delete username here

Option 2

sudo -u www-data php /var/www/nextcloud/occ ldap:show-remnants > user.txt

sudo -u www-data php /var/www/nextcloud/occ ldap:show-remnants | awk 'FNR > 3 {print $2}' | sed '$d' | xargs -L1 sudo -u www-data php /var/www/nextcloud/occ user:delete

@Bevito
Copy link
Author

Bevito commented Oct 15, 2022

Hi andyxheli,

The command 'occ ldap:show-remnants' works, but the commands 'occ user:delete' from option 1 or option 2 throw a PHP error :

Error: Call to undefined method OCA\User_LDAP\User\OfflineUser::getExtStorageHome() in /var/www/html/nextcloud/apps/user_ldap/lib/Handler/ExtStorageConfigHandler.php:65

@Bevito
Copy link
Author

Bevito commented Oct 21, 2022

Hi,

If I modify the file 'apps/user_ldap/lib/Handler/ExtStorageConfigHandler.php' at line 30 and If I replace
'use OCA\User_LDAP\User_Proxy;'
by
'use OCA\User_LDAP\User;'
the command 'sudo -u www-data php occ user:delete id-return-by-occ-ldap-show-remnants' works.

I really don't know why, but with 'User_Proxy' namesapce, the method getExtStorageHome() can't be found.

@Fantu
Copy link

Fantu commented Feb 6, 2023

hi, I also unable to delete nextcloud user profile connected with ldap on nextcloud (the server where I tried have version 22.2.10)
sudo -u www-data php /var/www/nextcloud/occ user:delete 47816D7C-DCD8-47B8-839B-0BAC52997BE7 The specified user could not be deleted. Please check the logs.
In my case I don't see related errors in nextcloud and apache logs.

EDIT:
after other test I saw that is unable to delete profile of user disabled in active directory, with user deleted on AD (... occ ldap:show-remnants) instead works correctly

@blizzz
Copy link
Member

blizzz commented Mar 22, 2023

#37346 should fix this if you like to try it out

@Bevito
Copy link
Author

Bevito commented Mar 22, 2023

Hi blizzz,

Thank you very much for your pull request and your help.
I just tested it and everything works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants