Lost external SMB after modifying LDAP samaccountname

Nextcloud version (eg, 29.0.5): 25.0.13
Operating system and version (eg, Ubuntu 29.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.56
PHP version (eg, 8.3): 7.4.33

The issue you are facing:
We use LDAP/AD for authentication to Nextcloud. As part of integration work with our new parent company, we have modifed the names of LDAP users that have admin rights (e.g. AD user djones became AD user dadmin-djones).

Login with the new LDAP credentials works fine. As does access to External Shares that use a fixed share name.

The user’s home shares no longer work. After logging in with the new credentials, we have discovered that nextcloud is still trying to access the former share name, rather than the updated share name (e.g. \server$home$user, attempts to reach $home\djones, rather than $home\dadmin-djones).

We have waited for the LDAP processes to attempt to resync; but, the link to the shares seems persistent. How do we clear this cached value?

Is this the first time you’ve seen this error? (Y/N):
Yes

Steps to replicate it:

  1. Create an account in NC using LDAP credentials
  2. Change the AD user name
  3. Change the share name to match the new AD username
  4. Login to NC using updated LDAP credentials
  5. Access the external storage for the user’s home directory
  6. NC will show the server “responded with an empty string”
  7. Create a new share using the old AD username
  8. Access the external storage again
  9. NC connects to storage and will show an empty folder

The output of your Nextcloud log in Admin > Logging:

PASTE HERE{"reqId":"2GKVCZLL2J64pslhCtr1","level":3,"time":"2024-06-28T18:34:08+00:00","remoteAddr":"198.143.57.48","user":"tcroes","app":"index","method":"GET","url":"/index.php/apps/files_external/globalstorages/1?testOnly=true","message":"Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php' line 61","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36","version":"25.0.13.2","exception":{"Exception":"Exception","Message":"Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php' line 61","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1053,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","Line":165,"Previous":{"Exception":"Error","Message":"Call to a member function getUID() on null","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":264,"function":"manipulateStorageConfig","class":"OCA\\Files_External\\Lib\\Auth\\Password\\SessionCredentials","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":281,"function":"manipulateStorageConfig","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":363,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"show","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1053,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php","Line":61},"CustomMessage":"--"},"id":"667f2343908b3"}

Are you using $user or $home in your variable mount paths for this External Storage?

https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/external_storage_configuration_gui.html#usage-of-variables-for-mount-paths

What is your Home Folder Naming Rule (if using)?

https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/user_auth_ldap.html#ldap-special-attributes

Home Folder Naming Rule is blank.

Yes, both. It’s an SMB/CIFS share with:
IP in the host field
home$ in Share
$user in the Remote subfolder, and
[our AD domain] in the Domain field.

I thought it odd that the Share name was “host$” rather than “$host”, so I updated it to $host and broke the share alltogether. Put it back as host$ and the shares are working - just to the wrong/old shares.