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:
  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 = \
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:


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.