Clean up Ldap user data after manual file deletion?

I’ve been testing owncloud/Nextcloud recently and after upgrading to Nextcloud I found my ldap user folders in the /data folder had names that were just numbers. I thought it was a bug so I deleted the /data folder and logged back in and found that the user directories were still numbers. I found that I had to add in to sort by the SID vs UUID.

Now that my user folders have a username in /data I found in the web interface it still thinks the files are on the server. I can’t remove them I get an error when I try to delete them (rightfully so since the file isn’t there).

My question, is there any way to clean out the user data in the database? @blizzz in the IRC channel someone said I should tag you. Let me know if you need any more detailed information. I will add I haven’t pushed this installation out into production yet so if needed I can start over. I’d just prefer to be able to fix an issue like this instead of having to reinstall.

I will add I don’t want to delete the user I was just trying to fix/clean up that /data directory and ended causing the issue.

thanks,

If the files within /data are not of importance - and it seems that’s most likely the case since its just testing - then here’s what I would do:

Delete or move all numbered folders (I assume they are UUID’s from your LDAP) within /data to /data.backup or something. Then go to your Admin page and under LDAP settings go all the way to Expert and click on the “Clear Username-LDAP User Mapping” button. Next to Internal Username Attribute on that same tab, type an LDAP variable that you want your folder to inherit. You can use cn, samaccountname, etc… personally i use the latter and my folders within /data are structured based on user’s lastname first initial (LastF).

I assume that’s what you intended to do =)
Let me know

I gave that a try but I hasn’t fixed the issue. I took a screenshot to show what I’m talking about.

See how in the website shows that those folders are there. If I click on a folder it shows the “files” there as well. The files aren’t there as the terminal window shows. So I’m assuming the database has information linking to the files and doesn’t just read from the /Data/Username directory.

Thanks for the suggestion.

Few questions so I try to understand your environment better:

If you’re on Ubuntu or similar, is there anything under /var/www/owncloud/data (or nextcloud/data in this case). I ask because I wonder, unlikely as it may be, if its reading from a different data folder. Like I said unlikely, because from your screenshot it looks like you may have setup the data folder on an external device.

Can you do a sudo ll /media/Data/owncloud/data/user/files and see if anything is there?

I moved the /data directory onto a separate VHD and it’s mounted on /media/Data(super original name of the drive). I updated the config.php to have the /data folder in that location. Before I noticed those folders being named wrong it was working in the /Data folder in it’s new location. I don’t believe that’s the issue. Also I did verify there isn’t a /data directory in the /var/www/owncloud folder.

If I upload a file/folder it updates currently and shows in the server’s HD as well as in the web interface. If I delete a “new” file it deletes properly. It’s only the files that were there before I did the Nextcloud upgrade that I can’t remove. Which is making me wonder if I should just scrap the DB and recreate it.

Okay definitely understand your situation better. I think I already know the answer but do any of the folders/files that you CANNOT remove listed if you sudo ll /media/Data/owncloud/data/user/files?

Nope the folder is currently empty.

For some reason I feel like removing all user folders within the /media/Data/owncloud/data folder, clearing the mappings and re-assigning the Internal Username Attribute to samaccountname should’ve fixed it - but obviously I’m wrong.

Unfortunately I cannot help any further - you may need recreate the server, which I realize does not help in understanding the problem but…at least you get what you need =)

I deleted my LDAP mapping and I’m going to let the server sit over night (not sure why but it sounds good) and then i’m going to try and put back in the LDAP settings. If that doesn’t’ fix it i’ll recreate the system but yeah. I’d like to find where those settings are and flush them out instead of having to re-create the whole server.

Try this too afterwards (check separately, so you know which solution worked if it indeed does work)::

sudo -u www-data php occ files:scan --all

Was the issue resolved?

Sorry I started moving out of my house so I didn’t have free time to work on this. I’m going to try to work on it tonight. The last step I took was removing my LDAP settings. Hoping it cleans up the database. I’ve got to try the occ fles:scan -all command yet.

Just re-setup the LDAP settings and it appears to be fixed now. The LDAP users new folder was “clean” and all of my newly uploaded/deleted files are appearing and going away appropriately. Thanks for the help.

Excellent! Glad I could be of help :grin:

2 Likes