Skip to content

fix(user_ldap): update the display name cache before announcing a rename - #67049

Open
Ivansss wants to merge 3 commits into
masterfrom
fix/ldap-display-name-cache-before-event
Open

Ivansss wants to merge 3 commits into
masterfrom
fix/ldap-display-name-cache-before-event

Conversation

@Ivansss

@Ivansss Ivansss commented Nov 26, 2026

Copy link
Copy Markdown
Member

When an LDAP display name changes, the avatar can end up showing the initials of the previous name.

composeAndStoreDisplayName() announces the change before the new name is written to the LDAP display name cache. Listeners act on the change right away: the address book card is rebuilt, and with it the avatar is regenerated. They read the display name from the cache, which still holds the previous name.

This PR writes the display name to the cache inside composeAndStoreDisplayName(), before the change is announced, and removes the now redundant cache writes after it in User::processAttributes() and Access::applyUserDisplayName(). The name is cached even when it didn't change, since an unchanged name isn't necessarily in the cache.

This builds on #67048. With the cache holding the new name, getAccount() returns it too, so without the Accounts\Hooks change from that PR the account data and the people search would no longer be updated on renames.

Reproduced and validated on a live instance (master + OpenLDAP):

  1. Create an LDAP user with a display name, log in, and look the user up so the name is cached.
  2. Change the display name in LDAP.
  3. Let Nextcloud pick it up: run occ ldap:check-user --update <uid>, or let the background sync job run.
  4. Before: the avatar shows the previous name's initials. After: the avatar, oc_accounts and the people search show the new name.

TODO

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

…ogin

When an LDAP user logs in before a display name is set, Nextcloud falls back
to the user id. Storing the display name for the first time was not announced
as a change, so the generated avatar, the account data and the address book
card kept showing the user id.

Assisted-by: ClaudeCode:claude-opus-5.5
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
@Ivansss
Ivansss requested review from a team as code owners November 26, 2026 16:17
@Ivansss
Ivansss requested review from Altahrim, come-nc and cristianscheid and removed request for a team November 26, 2026 16:17
@Ivansss Ivansss changed the title Fix/ldap display name cache before event fix(user_ldap): update the display name cache before announcing a rename Nov 26, 2026
@Ivansss
Ivansss force-pushed the fix/ldap-display-name-cache-before-event branch from 176c87a to f9e87d5 Compare November 27, 2026 10:25
The account already carries the display name of the user backend, so
comparing against it skipped updating the stored account data. Email
changes keep the comparison, as the account holds the stored email.

Assisted-by: ClaudeCode:claude-opus-5.5
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Listeners of the display name change, like the avatar regeneration through
the address book card, read the display name right away. They got the
previous name from the LDAP cache, so the avatar showed the old initials.

Assisted-by: ClaudeCode:claude-opus-5.5
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
@Ivansss
Ivansss force-pushed the fix/ldap-display-name-cache-before-event branch from f9e87d5 to d7594bc Compare November 27, 2026 12:00

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants