Find the file owner of a private link

If your ownCloud instance is quite large with a lot of users, you might run into the following problem:

  1. Somebody links to your ownCloud instance using a private link, documents it in a public place
  2. The original user might be deactivated, deleted, decommissioned or whatever and the link now shows the following:
    Screenshot_20220111_101545
  3. However it is not clear who was the original owner, the data seems important and not even the admin team seems to have access to that file

Then an administrator with database access can run the following query to find the original owner:

select mounts.user_id \
from oc_filecache as file, oc_filecache as parent, oc_mounts as mounts \
where file.storage = parent.storage \
and parent.parent=-1 \
and mounts.root_id = parent.fileid \
and file.fileid=<enter fileid>;

The fileid is just the final number at the end of the private link. So if your private link looks like this:

https://owncloud.domain.tld/f/16030137

It is 16030137 in this case.


In case you receive Empty set as response, check that the file itself still exists.

select * from oc_filecache where fileid=<enter fileid>;

If this still shows Emtpy set, the file has been deleted.

4 Likes