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]: Integrity constraint violation: 1062 Duplicate entry for key user_ldap_membership_unique #43496

Open
5 of 8 tasks
rpelissi opened this issue Feb 9, 2024 · 13 comments
Open
5 of 8 tasks
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 28-feedback bug feature: ldap

Comments

@rpelissi
Copy link

rpelissi commented Feb 9, 2024

⚠️ This issue respects the following points: ⚠️

Bug description

So I have upgrade to latest 28.02 versin using occ upgrade. Everything is working fine but received some popup from time to time saying that an administrator remove my user from an ldap group.
Now checking in the logs

DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'interne-romain.pelissier' for key 'user_ldap_membership_unique'

I am using groups and users from an openldap server and the ldap connection is/was working fine so far.
The issue happen after the update to 28.02

I see some references to this issue here #42576 and #42482 but not sure it really apply and cannot found a fix for this.

Steps to reproduce

  1. Have nextcloud 27.x using openldap and mysql db working
  2. Upgrade to 24.02 using the occ command

Expected behavior

We should not have this duplicate entry issue

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

RHEL/CentOS

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

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

Upgraded to a MAJOR version (ex. 22 to 23)

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***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.6.8",
            "cloud.digitalrat.org"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "cloud.digitalrat.org",
        "overwriteprotocol": "https",
        "overwrite.cli.url": "https:\/\/cloud.digitalrat.org\/",
        "htaccess.RewriteBase": "\/",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.2.5",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "filelocking.enabled": true,
        "updater.release.channel": "stable",
        "mysql.utf8mb4": true,
        "mail_sendmailmode": "smtp",
        "app_install_overwrite": [
            "twofactor_email"
        ],
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [
            "Utilisateurs"
        ],
        "twofactor_enforced_excluded_groups": [],
        "encryption.legacy_format_support": false,
        "encryption.key_storage_migrated": false,
        "default_phone_region": "CA",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "dbindex": 0,
            "timeout": 1.5
        },
        "maintenance_window_start": 1
    }
}

List of activated Apps

Enabled:
  - activity: 2.20.0
  - admin_audit: 1.18.0
  - calendar: 4.6.4
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - contacts: 5.5.1
  - contactsinteraction: 1.9.0
  - cookbook: 0.11.0
  - dashboard: 7.8.0
  - dav: 1.29.1
  - deck: 1.12.1
  - federatedfilesharing: 1.18.0
  - federation: 1.18.0
  - files: 2.0.0
  - files_external: 1.20.0
  - files_pdfviewer: 2.9.0
  - files_reminders: 1.1.0
  - files_sharing: 1.20.0
  - files_trashbin: 1.18.0
  - files_versions: 1.21.0
  - firstrunwizard: 2.17.0
  - groupfolders: 16.0.3
  - logreader: 2.13.0
  - lookup_server_connector: 1.16.0
  - nextcloud_announcements: 1.17.0
  - notes: 4.9.2
  - notifications: 2.16.0
  - oauth2: 1.16.3
  - password_policy: 1.18.0
  - photos: 2.4.0
  - privacy: 1.12.0
  - provisioning_api: 1.18.0
  - recommendations: 2.0.0
  - related_resources: 1.3.0
  - richdocuments: 8.3.1
  - serverinfo: 1.18.0
  - settings: 1.10.1
  - sharebymail: 1.18.0
  - support: 1.11.0
  - survey_client: 1.16.0
  - systemtags: 1.18.0
  - tasks: 0.15.0
  - text: 3.9.1
  - theming: 2.3.0
  - twofactor_backupcodes: 1.17.0
  - twofactor_email: 2.7.4
  - twofactor_nextcloud_notification: 3.8.0
  - twofactor_totp: 10.0.0-beta.2
  - updatenotification: 1.18.0
  - user_ldap: 1.19.0
  - user_status: 1.8.1
  - viewer: 2.2.0
  - weather_status: 1.8.0
  - workflowengine: 2.10.0
Disabled:
  - bruteforcesettings: 2.8.0 (installed 1.0.3)
  - encryption: 2.16.0 (installed 2.8.1)
  - files_antivirus: 5.4.1 (installed 5.4.1)
  - files_markdown: 2.4.1 (installed 2.4.1)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - ocr: 6.0.58 (installed 6.0.58)
  - suspicious_login: 6.0.0
  - twofactor_gateway: 0.20.0 (installed 0.20.0)
  - unsplash: 2.2.1 (installed 2.2.1)

Nextcloud Signing status

No errors have been found

Nextcloud Logs

{"reqId":"ZcQo7LNEtNtamhQm@rvEpAAAAFM","level":3,"time":"2024-02-08T01:05:49+00:00","remoteAddr":"192.168.7.30","user":"romain.pelissier","app":"no app in context","method":"PUT","url":"/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json","message":"Exception thrown: OC\\DB\\Exceptions\\DbalException","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","version":"28.0.2.5","exception":{"Exception":"OC\\DB\\Exceptions\\DbalException","Message":"An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'interne-romain.pelissier' for key 'user_ldap_membership_unique'","Code":1062,"Trace":[{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":328,"function":"wrap","class":"OC\\DB\\Exceptions\\DbalException","type":"::"},{"file":"/www/html/prod/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":137,"function":"executeStatement","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":95,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":67,"function":"updateGroups","class":"OCA\\User_LDAP\\LoginListener","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":55,"function":"onPostLogin","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":86,"function":"handle","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":230,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":59,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":94,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":106,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":392,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":667,"function":"completeLogin","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":868,"function":"loginWithToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/base.php","line":1145,"function":"tryTokenLogin","class":"OC\\User\\Session","type":"->"},{"file":"/www/html/prod/nextcloud/ocs/v1.php","line":62,"function":"handleLogin","class":"OC","type":"::"},{"file":"/www/html/prod/nextcloud/ocs/v2.php","line":23,"args":["/www/html/prod/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/www/html/prod/nextcloud/lib/private/DB/Exceptions/DbalException.php","Line":71,"Previous":{"Exception":"Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException","Message":"An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'interne-romain.pelissier' for key 'user_ldap_membership_unique'","Code":1062,"Trace":[{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1938,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1880,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1208,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/Connection.php","line":294,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":386,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":326,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":137,"function":"executeStatement","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":95,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":67,"function":"updateGroups","class":"OCA\\User_LDAP\\LoginListener","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":55,"function":"onPostLogin","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":86,"function":"handle","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":230,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":59,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":94,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":106,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":392,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":667,"function":"completeLogin","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":868,"function":"loginWithToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/base.php","line":1145,"function":"tryTokenLogin","class":"OC\\User\\Session","type":"->"},{"file":"/www/html/prod/nextcloud/ocs/v1.php","line":62,"function":"handleLogin","class":"OC","type":"::"},{"file":"/www/html/prod/nextcloud/ocs/v2.php","line":23,"args":["/www/html/prod/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":62,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'interne-romain.pelissier' for key 'user_ldap_membership_unique'","Code":1062,"Trace":[{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":132,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1202,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/Connection.php","line":294,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":386,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":326,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":137,"function":"executeStatement","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":95,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":67,"function":"updateGroups","class":"OCA\\User_LDAP\\LoginListener","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":55,"function":"onPostLogin","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":86,"function":"handle","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":230,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":59,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":94,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":106,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":392,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":667,"function":"completeLogin","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":868,"function":"loginWithToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/base.php","line":1145,"function":"tryTokenLogin","class":"OC\\User\\Session","type":"->"},{"file":"/www/html/prod/nextcloud/ocs/v1.php","line":62,"function":"handleLogin","class":"OC","type":"::"},{"file":"/www/html/prod/nextcloud/ocs/v2.php","line":23,"args":["/www/html/prod/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":28,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'interne-romain.pelissier' for key 'user_ldap_membership_unique'","Code":"23000","Trace":[{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":130,"function":"execute","class":"PDOStatement","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1202,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/Connection.php","line":294,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":386,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":326,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":137,"function":"executeStatement","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":95,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":67,"function":"updateGroups","class":"OCA\\User_LDAP\\LoginListener","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/apps/user_ldap/lib/LoginListener.php","line":55,"function":"onPostLogin","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":86,"function":"handle","class":"OCA\\User_LDAP\\LoginListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":230,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/www/html/prod/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":59,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":94,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":106,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":392,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":667,"function":"completeLogin","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/private/User/Session.php","line":868,"function":"loginWithToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/www/html/prod/nextcloud/lib/base.php","line":1145,"function":"tryTokenLogin","class":"OC\\User\\Session","type":"->"},{"file":"/www/html/prod/nextcloud/ocs/v1.php","line":62,"function":"handleLogin","class":"OC","type":"::"},{"file":"/www/html/prod/nextcloud/ocs/v2.php","line":23,"args":["/www/html/prod/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/www/html/prod/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":130}}},"CustomMessage":"Exception thrown: OC\\DB\\Exceptions\\DbalException"},"id":"65c6a70fa6143"}

Additional info

No response

@rpelissi rpelissi added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 9, 2024
@come-nc
Copy link
Contributor

come-nc commented Feb 13, 2024

Can you double check you do not have a duplicated LDAP configuration?
How many LDAP configuration do you see when running occ ldap:show-config?

@rpelissi
Copy link
Author

Here is the output of the command:

[root@pdrweb001 ~]# sudo -u apache php -f /www/html/prod/nextcloud/occ ldap:show-confi
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Configuration                 | s01                                                                                                                                                    |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                                                                                                                      |
| homeFolderNamingRule          |                                                                                                                                                        |
| lastJpegPhotoLookup           | 0                                                                                                                                                      |
| ldapAdminGroup                |                                                                                                                                                        |
| ldapAgentName                 | cn=ldapadmin,dc=digitalrat,dc=lan                                                                                                                      |
| ldapAgentPassword             | ***                                                                                                                                                    |
| ldapAttributeAddress          |                                                                                                                                                        |
| ldapAttributeBiography        |                                                                                                                                                        |
| ldapAttributeFediverse        |                                                                                                                                                        |
| ldapAttributeHeadline         |                                                                                                                                                        |
| ldapAttributeOrganisation     |                                                                                                                                                        |
| ldapAttributePhone            |                                                                                                                                                        |
| ldapAttributeRole             |                                                                                                                                                        |
| ldapAttributeTwitter          |                                                                                                                                                        |
| ldapAttributeWebsite          |                                                                                                                                                        |
| ldapAttributesForGroupSearch  |                                                                                                                                                        |
| ldapAttributesForUserSearch   |                                                                                                                                                        |
| ldapBackgroundHost            |                                                                                                                                                        |
| ldapBackgroundPort            |                                                                                                                                                        |
| ldapBackupHost                |                                                                                                                                                        |
| ldapBackupPort                |                                                                                                                                                        |
| ldapBase                      | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapBaseGroups                | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapBaseUsers                 | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapCacheTTL                  | 600                                                                                                                                                    |
| ldapConfigurationActive       | 1                                                                                                                                                      |
| ldapConnectionTimeout         | 15                                                                                                                                                     |
| ldapDefaultPPolicyDN          |                                                                                                                                                        |
| ldapDynamicGroupMemberURL     |                                                                                                                                                        |
| ldapEmailAttribute            | mail                                                                                                                                                   |
| ldapExperiencedAdmin          | 0                                                                                                                                                      |
| ldapExpertUUIDGroupAttr       | guid                                                                                                                                                   |
| ldapExpertUUIDUserAttr        | uid                                                                                                                                                    |
| ldapExpertUsernameAttr        | uid                                                                                                                                                    |
| ldapExtStorageHomeAttribute   |                                                                                                                                                        |
| ldapGidNumber                 | gidNumber                                                                                                                                              |
| ldapGroupDisplayName          | cn                                                                                                                                                     |
| ldapGroupFilter               | (&(|(objectclass=top))(|(cn=interne)))                                                                                                                 |
| ldapGroupFilterGroups         | interne                                                                                                                                                |
| ldapGroupFilterMode           | 1                                                                                                                                                      |
| ldapGroupFilterObjectclass    | top                                                                                                                                                    |
| ldapGroupMemberAssocAttr      | gidNumber                                                                                                                                              |
| ldapHost                      | ldaps://pdrldap01.digitalrat.lan                                                                                                                       |
| ldapIgnoreNamingRules         |                                                                                                                                                        |
| ldapLoginFilter               | (&(|(objectclass=sambaSamAccount))(|(uid=%uid)(|(mailPrimaryAddress=%uid)(mail=%uid))))                                                                |
| ldapLoginFilterAttributes     |                                                                                                                                                        |
| ldapLoginFilterEmail          | 1                                                                                                                                                      |
| ldapLoginFilterMode           | 1                                                                                                                                                      |
| ldapLoginFilterUsername       | 1                                                                                                                                                      |
| ldapMatchingRuleInChainState  | unknown                                                                                                                                                |
| ldapNestedGroups              | 0                                                                                                                                                      |
| ldapOverrideMainServer        |                                                                                                                                                        |
| ldapPagingSize                | 500                                                                                                                                                    |
| ldapPort                      | 636                                                                                                                                                    |
| ldapQuotaAttribute            |                                                                                                                                                        |
| ldapQuotaDefault              |                                                                                                                                                        |
| ldapTLS                       | 0                                                                                                                                                      |
| ldapUserAvatarRule            | default                                                                                                                                                |
| ldapUserDisplayName           | uid                                                                                                                                                    |
| ldapUserDisplayName2          |                                                                                                                                                        |
| ldapUserFilter                | (&(|(objectclass=inetOrgPerson)(objectclass=person)(objectclass=posixAccount)(objectclass=top))(|(memberof=cn=interne,ou=group,dc=digitalrat,dc=lan))) |
| ldapUserFilterGroups          | interne                                                                                                                                                |
| ldapUserFilterMode            | 0                                                                                                                                                      |
| ldapUserFilterObjectclass     | inetOrgPerson;person;posixAccount;top                                                                                                                  |
| ldapUuidGroupAttribute        | auto                                                                                                                                                   |
| ldapUuidUserAttribute         | auto                                                                                                                                                   |
| markRemnantsAsDisabled        | 0                                                                                                                                                      |
| turnOffCertCheck              | 0                                                                                                                                                      |
| turnOnPasswordChange          | 0                                                                                                                                                      |
| useMemberOfToDetectMembership | 1                                                                                                                                                      |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
You have new mail in /var/spool/mail/root

@rpelissi
Copy link
Author

Hi,
I have modified the group filter a bit and it seems to fix the issue:

[root@pdrweb001 ~]# sudo -u apache php -f /www/html/prod/nextcloud/occ ldap:show-confi
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Configuration                 | s01                                                                                                                                                    |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                                                                                                                      |
| homeFolderNamingRule          |                                                                                                                                                        |
| lastJpegPhotoLookup           | 0                                                                                                                                                      |
| ldapAdminGroup                |                                                                                                                                                        |
| ldapAgentName                 | cn=ldapadmin,dc=digitalrat,dc=lan                                                                                                                      |
| ldapAgentPassword             | ***                                                                                                                                                    |
| ldapAttributeAddress          |                                                                                                                                                        |
| ldapAttributeBiography        |                                                                                                                                                        |
| ldapAttributeFediverse        |                                                                                                                                                        |
| ldapAttributeHeadline         |                                                                                                                                                        |
| ldapAttributeOrganisation     |                                                                                                                                                        |
| ldapAttributePhone            |                                                                                                                                                        |
| ldapAttributeRole             |                                                                                                                                                        |
| ldapAttributeTwitter          |                                                                                                                                                        |
| ldapAttributeWebsite          |                                                                                                                                                        |
| ldapAttributesForGroupSearch  |                                                                                                                                                        |
| ldapAttributesForUserSearch   |                                                                                                                                                        |
| ldapBackgroundHost            |                                                                                                                                                        |
| ldapBackgroundPort            |                                                                                                                                                        |
| ldapBackupHost                |                                                                                                                                                        |
| ldapBackupPort                |                                                                                                                                                        |
| ldapBase                      | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapBaseGroups                | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapBaseUsers                 | dc=digitalrat,dc=lan                                                                                                                                   |
| ldapCacheTTL                  | 600                                                                                                                                                    |
| ldapConfigurationActive       | 1                                                                                                                                                      |
| ldapConnectionTimeout         | 15                                                                                                                                                     |
| ldapDefaultPPolicyDN          |                                                                                                                                                        |
| ldapDynamicGroupMemberURL     |                                                                                                                                                        |
| ldapEmailAttribute            | mail                                                                                                                                                   |
| ldapExperiencedAdmin          | 0                                                                                                                                                      |
| ldapExpertUUIDGroupAttr       | guid                                                                                                                                                   |
| ldapExpertUUIDUserAttr        | uid                                                                                                                                                    |
| ldapExpertUsernameAttr        | uid                                                                                                                                                    |
| ldapExtStorageHomeAttribute   |                                                                                                                                                        |
| ldapGidNumber                 | gidNumber                                                                                                                                              |
| ldapGroupDisplayName          | cn                                                                                                                                                     |
| ldapGroupFilter               | (&(|(objectclass=top))(|(memberof=cn=interne,ou=group,dc=digitalrat,dc=lan)))                                                                          |
| ldapGroupFilterGroups         |                                                                                                                                                        |
| ldapGroupFilterMode           | 1                                                                                                                                                      |
| ldapGroupFilterObjectclass    | top                                                                                                                                                    |
| ldapGroupMemberAssocAttr      | gidNumber                                                                                                                                              |
| ldapHost                      | ldaps://pdrldap01.digitalrat.lan                                                                                                                       |
| ldapIgnoreNamingRules         |                                                                                                                                                        |
| ldapLoginFilter               | (&(|(objectclass=sambaSamAccount))(|(uid=%uid)(|(mailPrimaryAddress=%uid)(mail=%uid))))                                                                |
| ldapLoginFilterAttributes     |                                                                                                                                                        |
| ldapLoginFilterEmail          | 1                                                                                                                                                      |
| ldapLoginFilterMode           | 1                                                                                                                                                      |
| ldapLoginFilterUsername       | 1                                                                                                                                                      |
| ldapMatchingRuleInChainState  | unknown                                                                                                                                                |
| ldapNestedGroups              | 0                                                                                                                                                      |
| ldapOverrideMainServer        |                                                                                                                                                        |
| ldapPagingSize                | 500                                                                                                                                                    |
| ldapPort                      | 636                                                                                                                                                    |
| ldapQuotaAttribute            |                                                                                                                                                        |
| ldapQuotaDefault              |                                                                                                                                                        |
| ldapTLS                       | 0                                                                                                                                                      |
| ldapUserAvatarRule            | default                                                                                                                                                |
| ldapUserDisplayName           | uid                                                                                                                                                    |
| ldapUserDisplayName2          |                                                                                                                                                        |
| ldapUserFilter                | (&(|(objectclass=inetOrgPerson)(objectclass=person)(objectclass=posixAccount)(objectclass=top))(|(memberof=cn=interne,ou=group,dc=digitalrat,dc=lan))) |
| ldapUserFilterGroups          | interne                                                                                                                                                |
| ldapUserFilterMode            | 0                                                                                                                                                      |
| ldapUserFilterObjectclass     | inetOrgPerson;person;posixAccount;top                                                                                                                  |
| ldapUuidGroupAttribute        | auto                                                                                                                                                   |
| ldapUuidUserAttribute         | auto                                                                                                                                                   |
| markRemnantsAsDisabled        | 0                                                                                                                                                      |
| turnOffCertCheck              | 0                                                                                                                                                      |
| turnOnPasswordChange          | 0                                                                                                                                                      |
| useMemberOfToDetectMembership | 1                                                                                                                                                      |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+

@rpelissi
Copy link
Author

Hi,
I just realized that the previous filter make no sense (it handle username as group...) so I am testing this:

[root@pdrweb001 ~]# sudo -u apache php -f /www/html/prod/nextcloud/occ ldap:show-config
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Configuration                 | s01
                                                                 |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1
                                                                 |
| homeFolderNamingRule          |
                                                                 |
| lastJpegPhotoLookup           | 0
                                                                 |
| ldapAdminGroup                |
                                                                 |
| ldapAgentName                 | cn=ldapadmin,dc=digitalrat,dc=lan
                                                                 |
| ldapAgentPassword             | ***
                                                                 |
| ldapAttributeAddress          |
                                                                 |
| ldapAttributeBiography        |
                                                                 |
| ldapAttributeFediverse        |
                                                                 |
| ldapAttributeHeadline         |
                                                                 |
| ldapAttributeOrganisation     |
                                                                 |
| ldapAttributePhone            |
                                                                 |
| ldapAttributeRole             |
                                                                 |
| ldapAttributeTwitter          |
                                                                 |
| ldapAttributeWebsite          |
                                                                 |
| ldapAttributesForGroupSearch  |
                                                                 |
| ldapAttributesForUserSearch   |
                                                                 |
| ldapBackgroundHost            |
                                                                 |
| ldapBackgroundPort            |
                                                                 |
| ldapBackupHost                |
                                                                 |
| ldapBackupPort                |
                                                                 |
| ldapBase                      | dc=digitalrat,dc=lan
                                                                 |
| ldapBaseGroups                | dc=digitalrat,dc=lan
                                                                 |
| ldapBaseUsers                 | dc=digitalrat,dc=lan
                                                                 |
| ldapCacheTTL                  | 600
                                                                 |
| ldapConfigurationActive       | 1
                                                                 |
| ldapConnectionTimeout         | 15
                                                                 |
| ldapDefaultPPolicyDN          |
                                                                 |
| ldapDynamicGroupMemberURL     |
                                                                 |
| ldapEmailAttribute            | mail
                                                                 |
| ldapExperiencedAdmin          | 0
                                                                 |
| ldapExpertUUIDGroupAttr       | guid
                                                                 |
| ldapExpertUUIDUserAttr        | uid
                                                                 |
| ldapExpertUsernameAttr        | uid
                                                                 |
| ldapExtStorageHomeAttribute   |
                                                                 |
| ldapGidNumber                 | gidNumber
                                                                 |
| ldapGroupDisplayName          | cn
                                                                 |
| ldapGroupFilter               | (&(|(objectclass=top))(|(cn=interne)))
                                                                 |
| ldapGroupFilterGroups         | interne
                                                                 |
| ldapGroupFilterMode           | 0
                                                                 |
| ldapGroupFilterObjectclass    | top
                                                                 |
| ldapGroupMemberAssocAttr      | gidNumber
                                                                 |
| ldapHost                      | ldaps://pdrldap01.digitalrat.lan
                                                                 |
| ldapIgnoreNamingRules         |
                                                                 |
| ldapLoginFilter               | (&(|(objectclass=sambaSamAccount))(|(uid=%uid)(|(mailPrimaryAddress=%uid)(mail=%uid))))                                                                |
| ldapLoginFilterAttributes     |
                                                                 |
| ldapLoginFilterEmail          | 1
                                                                 |
| ldapLoginFilterMode           | 1
                                                                 |
| ldapLoginFilterUsername       | 1
                                                                 |
| ldapMatchingRuleInChainState  | unknown
                                                                 |
| ldapNestedGroups              | 0
                                                                 |
| ldapOverrideMainServer        |
                                                                 |
| ldapPagingSize                | 500
                                                                 |
| ldapPort                      | 636
                                                                 |
| ldapQuotaAttribute            |
                                                                 |
| ldapQuotaDefault              |
                                                                 |
| ldapTLS                       | 0
                                                                 |
| ldapUserAvatarRule            | default
                                                                 |
| ldapUserDisplayName           | uid
                                                                 |
| ldapUserDisplayName2          |
                                                                 |
| ldapUserFilter                | (&(|(objectclass=inetOrgPerson)(objectclass=person)(objectclass=posixAccount)(objectclass=top))(|(memberof=cn=interne,ou=group,dc=digitalrat,dc=lan))) |
| ldapUserFilterGroups          | interne
                                                                 |
| ldapUserFilterMode            | 0
                                                                 |
| ldapUserFilterObjectclass     | inetOrgPerson;person;posixAccount;top
                                                                 |
| ldapUuidGroupAttribute        | auto
                                                                 |
| ldapUuidUserAttribute         | auto
                                                                 |
| markRemnantsAsDisabled        | 0
                                                                 |
| turnOffCertCheck              | 0
                                                                 |
| turnOnPasswordChange          | 0
                                                                 |
| useMemberOfToDetectMembership | 1
                                                                 |
+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+

So far so good.
Maybe my question will be silly and stupid but what the ldap groups are used for in nextcloud? Is there a mapping ldap group/nextcloud groups?
Never really used them but to filter which users can use nextcloud.
Thanks!

@come-nc
Copy link
Contributor

come-nc commented Feb 19, 2024

Yes there is a mapping and ldap groups appear as Nextcloud groups.
You should align you user filter and your login filter so that the login filter is the same thing with only the login mapping added.

@come-nc
Copy link
Contributor

come-nc commented Mar 5, 2024

@rpelissi Is that still a problem? If yes can you try 28.0.3?

@ichdasich
Copy link

fwiw i just ran into this with 28.0.3, it seems.

@ichdasich
Copy link

Ok, so, i just spend some time debugging this. The issue is that the regular job with id 52 (OCA\User_LDAP\Jobs\UpdateGroups) removes a user from all but one group, likely the login group as per ldap from time to time.

Maybe a timeout or sth. when retrieving groups being overly strict, hence falling back to the login group from the user object only?

Specifically, public function findGroupMemberships(string $groupid): array { in lib/Db/GroupMembershipMapper.php seems to only return a single group per user from time to time. I am not sure what triggers it; It was deterministic running occ background-job:execute -vvv --force-execute 52 for some time. Then i added a few debug statements, and now it does see all groups.

Could this be related to #42576, specifically #42576 (comment) ?

@come-nc
Copy link
Contributor

come-nc commented Mar 28, 2024

Are you sure your user<->group relation ship is correctly configured for Nextcloud to pick up?
What do you have as attribute mapping for group members?

Recently I’ve seen a lot of instances where group were detected through memberof but the other way was misconfigured. We should add a check for that at some point.

@ichdasich
Copy link

Moin,

This actually makes sense, i.e., if upon login group membership is established via 'memberOf', but the regular job iterates over the group entries.

Checking now, I indeed see that the config seems to have defaulted to use gidNumber as the group membership property (should, obviously, be member).

Changing between member and other attribute names also leads to groups being purged from oc_ldap_group_membership when running occ background-job:execute -vvv --force-execute 52 (and being added when this is changed back to member).

So, i think that this explains the occurrence of this.

However, what it does not explain is why this did not happen with NC27? Was there a change there?

@come-nc
Copy link
Contributor

come-nc commented Mar 28, 2024

Yes the way group membership is cached in database was changed.

@come-nc
Copy link
Contributor

come-nc commented Mar 28, 2024

See #39446

@ichdasich
Copy link

Thanks; I cannot speak for the original reporter, but from my reading of this issue, that should be the explanation.

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 28-feedback bug feature: ldap
Projects
None yet
Development

No branches or pull requests

5 participants