[python-win32] Re: Extracting share permissions
Roger Upole
rwupole at msn.com
Tue Jan 31 23:29:28 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,>>MarkThere are a couple of
>> different options for persisting a security
>> descriptor.buffer(security_descriptor)[:] retrieves the raw bytes in
>> binary form.This can be passed to pywintypes.SECURITY_DESCRIPTOR to
>> recreate thePySECURITY_DESCRIPTOR.Also, you can use
>> win32security.ConvertSecurityDescriptorToStringSecurityDescriptorto
>> create a text representation
>> andwin32security.ConvertStringSecurityDescriptorToSecurityDescriptorto
>> recreate the PySECURITY_DESCRIPTOR.That reminds me, there's a bug in the
>> routine in win32net that parses infoout of dictionaries. If you pass in
>> None to indicate a NULL security descriptor,you get an access violation.
>> I'll get a fix in for that soon. Roger
More information about the Python-win32
mailing list