[python-win32] Extracting share permissions

Mark Hammond mhammond at skippinet.com.au
Tue Jan 31 23:00:40 CET 2006


> Mark, would you write an example of this using SHARE_INFO_502?

I'm afraid I don't have the time to do it all.

As a clue:

>>> import pprint
>>> pprint.pprint(win32net.NetShareEnum(None, 502))
([{'current_uses': 0,
   'max_uses': -1,
   'netname': u'IPC$',
   'passwd': None,
   'path': u'',
   'permissions': 0,
   'remark': u'Remote IPC',
   'reserved': 0,
   'security_descriptor': None,
   'type': -2147483645},
...

Note that far more details than just the share name are returned, all of
which are probably useful.  One of these is the security_descriptor object.
Some shares will show this as:

 'security_descriptor': <PySECURITY_DESCRIPTOR object at 0x00B6CE88>,

A security_descriptor object probably can't be directly pickled, so it may
be necessary to look at the win32 APIs for extracting the SIDs etc from this
SD and pickling them.  Sadly that isn't my area of expertise, so it will
take me a little time to find the necessary magic.  Google probably is your
friend though, as using SECURITY_DESCRIPTOR and SID objects has come up here
in the past.

Cheers,

Mark



More information about the Python-win32 mailing list