Solved Unable to retrieve file owner information from my code. (1 Viewer)

Sampoline

Member
Local time
Today, 20:15
Joined
Oct 19, 2020
Messages
161
Hi all, I've got some code here for File Listing. Which will go into "tblMetadata". Now I've been trying to figure out how to incorporate the File Owner data into this, but a little stuck. After some browsing, I realized there are slightly different ways to do it. But not sure how to make any of them work with my code.

I've attached a sample database of my db here, some help would be appreciated.
 

Attachments

  • Example.zip
    20 KB · Views: 112

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 28, 2001
Messages
27,229
There is a really complex way to do this involving trying to find the security information, which is an array of values that will give you the SID of the file owner. OR... there is the backdoor method that might or might not work for you.

Purists will try to use a WinAPI call to get the security information for a file. Here is an article that might help you.


The "backdoor" is actually more convoluted but gives you everything you need in one place. Consider spawning a shell with a command prompt. Send through two commands:

CD {some-folder-name-of-interest]
DIR /Q > {some file name}


Then open the "some file name" that was output by the redirection (the ">" symbol redirects program output to a file). That will give you a list of files in the "some-folder-of-interest" folder along with their dates of creation, "<DIR>" if the file on that row is a directory, the numeric file size if NOT a directory, the file owner NAME, and the file name & type. You could parse that out because the DIR command makes those fields always align, i.e. fixed width. Should be easily parsed with just a little bit of attention to columns. Try it manually yourself to see what the output looks like because you will see that it will give you pretty good alignment of the columns in question.

You would have to read several lines looking for something that says "Directory of {some-folder-name-of-interest}" after which you would skip one (blank) line and start reading the directory contents. Once you are in the directory area, the next fully blank line is the end of the folder list.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:15
Joined
May 7, 2009
Messages
19,247
see if this will work.
 

Attachments

  • Example.zip
    88.8 KB · Views: 95

Users who are viewing this thread

Top Bottom