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

Nextcloud 13: User changes do not get displayed #9112

Closed
kroerig opened this issue Apr 6, 2018 · 21 comments · Fixed by #12054
Closed

Nextcloud 13: User changes do not get displayed #9112

kroerig opened this issue Apr 6, 2018 · 21 comments · Fixed by #12054

Comments

@kroerig
Copy link

kroerig commented Apr 6, 2018

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 | +-------------------------------+------------------------------------------------------------------------------------------------------------------+
@rullzer
Copy link
Member

rullzer commented Apr 10, 2018

@nextcloud/ldap

@blizzz
Copy link
Member

blizzz commented Apr 10, 2018

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.

@kroerig
Copy link
Author

kroerig commented Apr 10, 2018

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.

@blizzz
Copy link
Member

blizzz commented Apr 10, 2018

@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?

@kroerig
Copy link
Author

kroerig commented Apr 10, 2018

https://archiv.leibniz-remscheid.de/nextcloud.log.bz2 (9.2MB, uncompressed 400MB)

@TomGem
Copy link

TomGem commented Jun 18, 2018

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

@TomGem
Copy link

TomGem commented Jun 28, 2018

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..

@kroerig
Copy link
Author

kroerig commented Jul 3, 2018

I tried your commands

occ user:setting USERNAME user_ldap displayName

already shows the right value.

@kroerig
Copy link
Author

kroerig commented Jul 4, 2018

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?

@TomGem
Copy link

TomGem commented Jul 6, 2018

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.

@blizzz
Copy link
Member

blizzz commented Oct 25, 2018

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

@kroerig
Copy link
Author

kroerig commented Oct 26, 2018

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.

@blizzz
Copy link
Member

blizzz commented Oct 26, 2018

@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.

@kroerig
Copy link
Author

kroerig commented Oct 26, 2018

Howto?

@blizzz
Copy link
Member

blizzz commented Oct 26, 2018

@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)

@kroerig
Copy link
Author

kroerig commented Oct 28, 2018

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.

@blizzz
Copy link
Member

blizzz commented Oct 29, 2018

@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);
 			}
 		}

@kroerig
Copy link
Author

kroerig commented Oct 29, 2018

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.

@blizzz
Copy link
Member

blizzz commented Oct 29, 2018

@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! :)

blizzz added a commit that referenced this issue Oct 30, 2018
only write when the displayname differs, but then announce it

refs #5212 and fixes #9112

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

do not run into UniqueConstraintViolationException

… 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>
blizzz added a commit that referenced this issue Oct 30, 2018
only write when the displayname differs, but then announce it

refs #5212 and fixes #9112

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

do not run into UniqueConstraintViolationException

… 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>
@MorrisJobke MorrisJobke added this to the Nextcloud 15 milestone Oct 30, 2018
@kroerig
Copy link
Author

kroerig commented Nov 11, 2018

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

@blizzz
Copy link
Member

blizzz commented Nov 13, 2018

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants