[python-win32] windows file name property

Tim Roberts timr at probo.com
Fri Mar 14 23:14:32 CET 2008


Chris Johnson wrote:
>
>  
>
> I am trying to print the attributes of a file.
>
>  
>
> The want I am most interested in is the owner. This is on windows xp.
>
>  
>
> Any help would be appreciated.
>

import win32security
o = win32security.GetFileSecurity( filename, 
win32security.OWNER_SECURITY_INFORMATION )
s = o.GetSecurityDescriptorOwner()
# This prints the SID form:
print str(s)
# PySID:S-1-5-21-1709892333-1682012616-2269307891-1141
# This gets the human-readable form:
s2 = sec.LookupAccountSid( '.', s )
print s2
# (u'timr', u'PROBO', 1)

That says this file is owned by user "timr" in domain "PROBO".  The "1" 
means this is a user, not a group (win32security.SidTypeUser).

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list