Skip to content

Nextcloud 13: User changes do not get displayed #9112

Closed

Description

@kroerig

Hello,

I'm using LDAP as user source. Now I had to change some users last names und logins because of marrige. But the changes do not get into Nextcloud.

Steps to reproduce

  1. Change a users last/first name in LDAP
  2. Log into Netzcloud
  3. Search for the "new" user in Contacts

Expected behaviour

The user should be displayed with the new values

Actual behaviour

The user is show with his old data. On CLI occ display the new data.

Server configuration

Operating system: Debian 8.10

Web server: Apache

Database: MySQL

PHP version: 5.6.33

Nextcloud version: 13.0.1

Updated from an older Nextcloud/ownCloud or fresh install: Migrated from OC

Where did you install Nextcloud from: tar ball

Signing status:

Signing status

No errors have been found.

List of activated apps:

App list Enabled: - activity: 2.6.1 - admin_audit: 1.3.0 - admin_notifications: 1.0.1 - announcementcenter: 3.2.1 - audioplayer: 2.2.5 - bruteforcesettings: 1.0.3 - checksum: 0.3.5 - circles: 0.13.6 - comments: 1.3.0 - dav: 1.4.6 - federatedfilesharing: 1.3.1 - files: 1.8.0 - files_accesscontrol: 1.3.0 - files_automatedtagging: 1.3.0 - files_downloadactivity: 1.2.0 - files_pdfviewer: 1.2.1 - files_retention: 1.2.0 - files_sharing: 1.5.0 - files_texteditor: 2.5.1 - files_trashbin: 1.3.0 - files_versions: 1.6.0 - files_videoplayer: 1.2.0 - firstrunwizard: 2.2.1 - gallery: 18.0.0 - groupfolders: 1.2.0 - impersonate: 1.0.3 - logreader: 2.0.0 - lookup_server_connector: 1.1.0 - metadata: 0.6.0 - nextcloud_announcements: 1.2.0 - notifications: 2.1.2 - oauth2: 1.1.0 - password_policy: 1.3.0 - provisioning_api: 1.3.0 - quota_warning: 1.2.0 - richdocuments: 2.0.5 - serverinfo: 1.3.0 - sharebymail: 1.3.0 - spreed: 3.1.0 - survey_client: 1.1.0 - systemtags: 1.3.0 - theming: 1.4.1 - twofactor_backupcodes: 1.2.3 - updatenotification: 1.3.0 - user_ldap: 1.3.1 - workflowengine: 1.3.0 Disabled: - encryption - federation - files_external - user_external

Nextcloud configuration:

Config report "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ ***REMOVED SENSITIVE VALUE***", ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "memcache.local": "\\OC\\Memcache\\APCu", "dbtype": "mysql", "version": "13.0.1.1", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "forcessl": true, "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_smtpmode": "php", "mail_domain": "***REMOVED SENSITIVE VALUE***", "preview_libreoffice_path": "\/usr\/bin\/libreoffice", "loglevel": 3, "ldapIgnoreNamingRules": false, "ldapUserCleanupInterval": 30, "preview_max_x": 100, "preview_max_y": 100, "theme": "", "secret": "***REMOVED SENSITIVE VALUE***", "maintenance": false, "trashbin_retention_obligation": "auto", "updater.release.channel": "stable", "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory", "overwrite.cli.url": ***REMOVED SENSITIVE VALUE***", "htaccess.RewriteBase": "\/"

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: no

Are you using an external user-backend, if yes which one: LDAP

LDAP configuration (delete this part if not used)

LDAP config +-------------------------------+------------------------------------------------------------------------------------------------------------------+ | Configuration | | +-------------------------------+------------------------------------------------------------------------------------------------------------------+ | hasMemberOfFilterSupport | | | hasPagedResultSupport | | | homeFolderNamingRule | | | lastJpegPhotoLookup | 0 | | ldapAgentName | | | ldapAgentPassword | *** | | ldapAttributesForGroupSearch | | | ldapAttributesForUserSearch | sn;givenname | | ldapBackupHost | | | ldapBackupPort | | | ldapBase | ***REMOVED SENSITIVE VALUE*** | | ldapBaseGroups | ou=Klassen,ou=Verteiler,***REMOVED SENSITIVE VALUE*** | | ldapBaseUsers | ou=Benutzer,***REMOVED SENSITIVE VALUE*** | | ldapCacheTTL | 600 | | ldapConfigurationActive | 1 | | ldapDefaultPPolicyDN | | | ldapDynamicGroupMemberURL | | | ldapEmailAttribute | mailLocalAddress | | ldapExperiencedAdmin | 0 | | ldapExpertUUIDGroupAttr | | | ldapExpertUUIDUserAttr | | | ldapExpertUsernameAttr | | | ldapGidNumber | gidNumber | | ldapGroupDisplayName | cn | | ldapGroupFilter | (&(|(objectclass=posixGroup))) | | ldapGroupFilterGroups | | | ldapGroupFilterMode | 0 | | ldapGroupFilterObjectclass | posixGroup | | ldapGroupMemberAssocAttr | memberUid | | ldapHost | localhost | | ldapIgnoreNamingRules | | | ldapLoginFilter | (&(|(objectclass=inetOrgPerson))(uid=%uid)) | | ldapLoginFilterAttributes | | | ldapLoginFilterEmail | 0 | | ldapLoginFilterMode | 0 | | ldapLoginFilterUsername | 1 | | ldapNestedGroups | 0 | | ldapOverrideMainServer | 0 | | ldapPagingSize | 500 | | ldapPort | 389 | | ldapQuotaAttribute | ownCloudQuota | | ldapQuotaDefault | 209715200 | | ldapTLS | 0 | | ldapUserDisplayName | displayname | | ldapUserDisplayName2 | | | ldapUserFilter | (|(objectclass=inetOrgPerson)) | | ldapUserFilterGroups | | | ldapUserFilterMode | 1 | | ldapUserFilterObjectclass | inetOrgPerson | | ldapUuidGroupAttribute | auto | | ldapUuidUserAttribute | auto | | turnOffCertCheck | 0 | | turnOnPasswordChange | 0 | | useMemberOfToDetectMembership | 0 | +-------------------------------+------------------------------------------------------------------------------------------------------------------+

Activity

  1. rullzer commented on Apr 10, 2018

    @rullzer
    Member

    @nextcloud/ldap

  2. blizzz commented on Apr 10, 2018

    @blizzz
    Member

    There's a cache holding data for 10 minutes (by default). I guess that kicked in. I am not aware of any issues, and saw it also working as expected on a change on our instance just recently.

  3. kroerig commented on Apr 10, 2018

    @kroerig
    Author

    I edited the user account about 4 days ago und NC still displays the old name in the contact search.
    But with the new email and the "talk to" button also shows the new name.

  4. blizzz commented on Apr 10, 2018

    @blizzz
    Member

    @kroerig then, for some reasons, the local addressbook (where the contactsmenu get its data from) was not updated. Could you provide your Nextcoud log file?

  5. kroerig commented on Apr 10, 2018

    @kroerig
    Author
  6. TomGem commented on Jun 18, 2018

    @TomGem

    I'm having the same issue.
    'Contacts' on the upper right seems to use the table 'oc_cards', which does not get updated if LDAP values change. As marriage is quite common if there are a few thousand accounts, I often have to correct the 'carddata' BLOB in 'oc_cards' manually.

    'occ user:info username' on the other hand displays the correct values

  7. TomGem commented on Jun 28, 2018

    @TomGem

    Fyi @kroerig, for now you could update Nextcloud users manually.

    alias occ="sudo -u www-data php /var/www/html/occ"
    
    # read values
    occ user:setting USERNAME user_ldap displayName
    occ user:setting USERNAME settings email
    
    # write values
    occ user:setting USERNAME user_ldap displayName "Firstname Lastname"
    occ user:setting USERNAME settings email "user@host.org"

    I wrote a little script to get the current values with ldapsearch and set them with occ if needed.
    Does not work..

  8. kroerig commented on Jul 3, 2018

    @kroerig
    Author

    I tried your commands

    occ user:setting USERNAME user_ldap displayName

    already shows the right value.

  9. kroerig commented on Jul 4, 2018

    @kroerig
    Author

    Today I had the next user that had to be renamed. Same problem. Now I'm on NC 13.0.4.

    'Contacts' on the upper right seems to use the table 'oc_cards',

    I found the wrong values also in 'oc_cards_properties'. This one seems to be used for seaching of contacts.

    Can I clear both tables and have NC populate them again?

  10. TomGem commented on Jul 6, 2018

    @TomGem

    You're right, oc_cards does not get updated when changing the displayName.

    I'd interested in a way to repopulate oc_cards from ldap too.

  11. added a commit that references this issue on Oct 25, 2018
    bbe4410
  12. blizzz commented on Oct 25, 2018

    @blizzz
    Member

    fix in #12054, would be awesome if you could test it

  13. kroerig commented on Oct 26, 2018

    @kroerig
    Author

    I tested and for me it does not work.
    But I'm on 14.0.3 now.

    I changed LDAP:displayname and also tried LDAP:givenname and LDAP:sn
    NC displays the old values on the users settings page, too.

    Is it possible that NC does this changes in the backgroud via cron, too? The problem is that not all users log into NC regulary, but others search for them.

  14. blizzz commented on Oct 26, 2018

    @blizzz
    Member

    @kroerig you would need to apply the patch, first.

    Is it possible that NC does this changes in the backgroud via cron, too? The problem is that not all users log into NC regulary, but others search for them.

    Yes, we switched to update user date from LDAP in a background job (unless the mode is still ajax), apart from first fetch and on logins.

  15. kroerig commented on Oct 26, 2018

    @kroerig
    Author

    Howto?

  16. blizzz commented on Oct 26, 2018

    @blizzz
    Member

    @kroerig

    1. Back up app/user_ldap/lib/User/User.php
    2. Download https://patch-diff.githubusercontent.com/raw/nextcloud/server/pull/12054.patch
    3. Remove everything after and including diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php (it is a test file and those are not shipped with the releases)
    4. from you Nextcloud root folder execute: patch -p1 < 12054.patch
    5. done

    (In case of errors, copy to the backed up file back to its place)

  17. kroerig commented on Oct 28, 2018

    @kroerig
    Author

    Remove everything **after and including** shure? That would mean an empty file
    That does not work.

    I only get patch: **** Only garbage was found in the patch input.

  18. blizzz commented on Oct 29, 2018

    @blizzz
    Member

    @kroerig you were a bit overeager in trimming it down. Copy that into a file (I added a commit anyhow):

    From bbe44108b5661d0c3935fa76e27abbc433fd458e Mon Sep 17 00:00:00 2001
    From: Arthur Schiwon <blizzz@arthur-schiwon.de>
    Date: Thu, 25 Oct 2018 23:41:12 +0200
    Subject: [PATCH 1/2] only write when the displayname differs, but then
     announce it
    
    refs #5212 and fixes #9112
    
    Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
    ---
     apps/user_ldap/lib/User/User.php       | 11 +++++++++--
     apps/user_ldap/tests/User/UserTest.php | 25 +++++++++++++++++++++++++
     2 files changed, 34 insertions(+), 2 deletions(-)
    
    diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
    index 02764a72eca..4afc8032f73 100644
    --- a/apps/user_ldap/lib/User/User.php
    +++ b/apps/user_ldap/lib/User/User.php
    @@ -414,14 +414,21 @@ private function store($key, $value) {
     	 *
     	 * @param string $displayName
     	 * @param string $displayName2
    -	 * @returns string the effective display name
    +	 * @return string the effective display name
     	 */
     	public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
     		$displayName2 = (string)$displayName2;
     		if($displayName2 !== '') {
     			$displayName .= ' (' . $displayName2 . ')';
     		}
    -		$this->store('displayName', $displayName);
    +		$oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', '');
    +		if ($oldName !== $displayName) {
    +			$this->store('displayName', $displayName);
    +			$user = $this->userManager->get($this->getUsername());
    +			if ($user instanceof \OC\User\User) {
    +				$user->triggerChange('displayName', $displayName);
    +			}
    +		}
     		return $displayName;
     	}
     
    
    From 9adf5422a2b3f44018a99a0979cda3f6e297a253 Mon Sep 17 00:00:00 2001
    From: Arthur Schiwon <blizzz@arthur-schiwon.de>
    Date: Fri, 26 Oct 2018 17:38:42 +0200
    Subject: [PATCH 2/2] do not run into UniqueConstraintViolationException
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    … when an unmapped user logs in for the first time when background job
    mode is ajax and no memcache was configured.
    
    Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
    ---
     apps/user_ldap/lib/User/User.php | 8 +++++---
     1 file changed, 5 insertions(+), 3 deletions(-)
    
    diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
    index 4afc8032f73..f4be19a7ad5 100644
    --- a/apps/user_ldap/lib/User/User.php
    +++ b/apps/user_ldap/lib/User/User.php
    @@ -421,11 +421,13 @@ public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
     		if($displayName2 !== '') {
     			$displayName .= ' (' . $displayName2 . ')';
     		}
    -		$oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', '');
    -		if ($oldName !== $displayName) {
    +		$oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', null);
    +		if ($oldName !== $displayName)  {
     			$this->store('displayName', $displayName);
     			$user = $this->userManager->get($this->getUsername());
    -			if ($user instanceof \OC\User\User) {
    +			if (!empty($oldName) && $user instanceof \OC\User\User) {
    +				// if it was empty, it would be a new record, not a change emitting the trigger could
    +				// potentially cause a UniqueConstraintViolationException, depending on some factors.
     				$user->triggerChange('displayName', $displayName);
     			}
     		}
    
  19. kroerig commented on Oct 29, 2018

    @kroerig
    Author

    hm, seams that one of my tries work.
    patching file apps/user_ldap/lib/User/User.php Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch.

    Got a new marrige announcemet for this weekend. Will try then.

  20. blizzz commented on Oct 29, 2018

    @blizzz
    Member

    @kroerig best, copy back the backup and apply the new patch. i fixed a corner case inbetween, that probably does not affect you, nevertheless better to have the current code :) and, thanks for testing! :)

  21. added 2 commits that reference this issue on Oct 30, 2018
    bdb8e37
    908e6be
  22. added this to the Nextcloud 15 milestone on Oct 30, 2018
  23. kroerig commented on Nov 11, 2018

    @kroerig
    Author

    @blizzz
    The displayname was changed but email still shows the old value.

  24. blizzz commented on Nov 13, 2018

    @blizzz
    Member

    @kroerig email address changes are already done via the core user object and it propagates changes.

    Best clue: from a previous state the email was the same as saved as user preference, but the addressbook contained a different value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions