[python-win32] Re: Folder permissions

Ryan Parrish RyanP at foxracing.com
Sat Jan 29 02:02:37 CET 2005


Here is what I have as a little test...

import os, win32security, ntsecuritycon

for root, dirs, files in os.walk("c:\\"):
    sd= win32security.GetFileSecurity(root,
win32security.GROUP_SECURITY_INFORMATION)
    sid= sd.GetSecurityDescriptorGroup()
    print root,"  ", win32security.LookupAccountSid(None, sid)

I do have the necessary permission as I am a local admin on my box.
Using OWNER_SECURITY_INFORMATION correctly returns owner of the
file/directory, but with GROUP_SECURITY_INFORMATION it returns seemingly
random groups from my domain that I absolutely know are not assigned on
my box (yes I checked also), besides it only seems to return one group -
I'm looking for all the groups that have access to the folder.

Ah, now I see that win32security.GetNamedSecurityInfo, that's what they
are talking about with the example, I totally didn't get that doh! Let
me see if I can figure out win32security.GetNamedSecurityInfo.

 


-Ryan Parrish 
-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Roger Upole
Sent: Friday, January 28, 2005 4:45 PM
To: python-win32 at python.org
Subject: [python-win32] Re: Folder permissions

GetFileSecurity should be able to pick up the correct info, assuming you
have sufficient permission to read the security descriptor.
Does it pick up any permissions at all ?

GetNamedSecurityInfo which the fileperm c code uses is also in the
win32security module.

What leads you to conclude that the group info is wrong ?

        Roger



_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


More information about the Python-win32 mailing list