Get file owner in Windows
ny_r_marquez at yahoo.com
Sat Nov 10 15:53:40 CET 2001
Thak you for the response, but I get an empthy string as a result.
(What is the /q switch supposed to do?). Any way, I was able to find
that in ActiveState's site there is a way to do this, with Perl. Here
is the link:
I was also able to find a solution by Microsoft, in VB.
The summary of that article says:
Retrieving the owner of a file requires obtaining the security
descriptor for the file, then using the security descriptor to get a
pointer to the owner's Security Identifier (SID). Finally, you use the
owner's SID to obtain the owner and domain name of the file.
Someone named Itamar posted this same question to the Python-win32
Here is what it says:
lets say I want to get the security information on a
file. So I do:
>>> o = win32security.GetFileSecurity(r"c:\mingc.pyd",
<PySECURITY_DESCRIPTOR object at 010E9350>
So what do I do with 'o' now in order to get the
owner? I tried:
>>> s = win32security.SID(o)
>>> win32security.LookupAccountSid(None, s)
Traceback (innermost last):
File "<interactive input>", line 1, in ?
api_error: (1332, 'LookupAccountSid', 'No mapping
between account names and security IDs was done.')
What am I doing wrong?
No one responded to his post. I get the same results that he does. I
have also looked through Mark's "Pyhton Programming on Win32" (good
book, by the way), but it does not seem to have this information
either. Does anyone have the knowhow to make Itamar's code work?
PS: <a href="http://linuxtoday.com/">Just testing.</a>
More information about the Python-list