I would like to query my Perforce server to get a list of all users who have an active workspace whose view specification references a given file in the depot.
For example, given the file //root/folder/file.txt this command should return a list of the users who have an active workspace whose view specification references //root/folder/file.txt
Alternatively the command could just return the workspaces that reference the file, and then it should be straight forward to get the list of owners of those workspaces.
First you'll get the workspaces, and then you can run through the list of workspaces to get the owner.
To get the workspaces you will need to loop over every workspace in your server and run(assuming your filename from the question):
If you get a 'no such files' error, then the workspace doesn't have any version of that file synced. For all of the workspaces that do have the file, you can then look up the owner in the spec.
Note that this query is checking to see if the workspace has the file synced, not just mapped. My general assumption is if they map it and don't sync it, the file is nearly as good as unmapped.