SPJ wrote:
I have googled on this but have not found a way to get security permissions of all the folders on a remote file share using python win32 module.

(I hope you know how NTFS security works, because while it's not necessarily
used that way, it can get a lot more complex than you might imagine.)

It's not clear (to me) whether the files are accessible to you from your
machine, but merely happen to be on a remote machine (ie you're
doing something like \\other-box\share1\dir\filename); or whether
you don't have access from your own machine and need some kind
of remote access toolset.

If the former, you've got a few options (see below). If the latter, you're
more limited, and WMI is probably the way to go.

One possibility is to use the cacls or xcacls command line tools to dump
the information out. This is pretty much exactly what they're designed to
do and they've already done the hard work of determining what's what
inside the DACL which you'd otherwise have to do. The downside is that
you'd have to parse their output (unless simply dumping it out to a log
is acceptable for your purposes).

A second possibility is to use the low-level Win32 API to query the security
yourself, essentially rolling your own cacls. This has the advantage that you
can produce exactly the output you want in the format you need, but the
disadvantage that you have to do it all yourself, including working through
allow and deny ACEs and inheritance issues. As a trivial starting point,
you can have a look at these:

http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html
http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html

which are clearly only starting points for what you want to do. Look also at the examples in the demos folder of the pywin32 extensions.

You could also consider WMI which may be your only possibility if you need to
access the security on remote machines (as opposed to via a share). This
will take you only a little higher than the Win32 APIs: you still have to do a 
fair
bit of work yourself. But it does allow you to perform the same check across
a number of machines.

I don't have a WMI security example, but if you wanted to go that way I could
run one up.

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to