64 lines
2.0 KiB
Plaintext
64 lines
2.0 KiB
Plaintext
From: MHammond at skippinet.com.au (Mark Hammond)
|
|
Date: Wed, 21 Apr 1999 20:22:09 +1000
|
|
Subject: permissions on win32 [Q]
|
|
References: <001201be8ba6$f2f706e0$6eba0ac8@kuarajy.infosys.com.ar>
|
|
Message-ID: <7fk8r0$7ng$1@m2.c2.telstra-mm.net.au>
|
|
Content-Length: 1677
|
|
X-UID: 1520
|
|
|
|
NT security is a bit of a black art. Build 124 has
|
|
win32security.SetFileSecurity().
|
|
|
|
The next question will be how to create a security descriptor - here is some
|
|
sample code.
|
|
|
|
[Oh damn - just realised that pywintypes.SECURITY_DESCRIPTOR() doesnt
|
|
actually exist in 124 - it will in 125. sorry - you will probably get stuck
|
|
here... But Ill still post it as reference for build 125 and later]
|
|
|
|
Mark.
|
|
|
|
def CreateSD(userName):
|
|
sd = pywintypes.SECURITY_DESCRIPTOR()
|
|
|
|
sidUser = win32security.LookupAccountName(None,userName)[0]
|
|
sidCreator = pywintypes.SID()
|
|
sidCreator.Initialize(ntsecuritycon.SECURITY_CREATOR_SID_AUTHORITY,1)
|
|
sidCreator.SetSubAuthority(0, ntsecuritycon.SECURITY_CREATOR_OWNER_RID)
|
|
|
|
acl = pywintypes.ACL()
|
|
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
|
|
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidCreator)
|
|
|
|
sd.SetSecurityDescriptorDacl(1, acl, 0)
|
|
return sd
|
|
|
|
Bruno Mattarollo wrote in message
|
|
<001201be8ba6$f2f706e0$6eba0ac8 at kuarajy.infosys.com.ar>...
|
|
>Hi!
|
|
>
|
|
> I have to do a little script for a customer that will copy files from an
|
|
NT
|
|
>server to another. I need to change the permissions on those files and
|
|
>directories. I mean, I need to give privileges to groups like
|
|
>Administrators, the user that owns the files (changes from file to file)
|
|
and
|
|
>other special groups. Anyone knows how to do this with Python? We have the
|
|
>following env: NT4SP4, Python 1.5.1, Win32All 124 ... the lastest one. I
|
|
>have already done the script that copies the files, I just need to know how
|
|
>to set this permissions.
|
|
>
|
|
> TIA
|
|
>
|
|
>/B
|
|
>
|
|
>Bruno Mattarollo <bruno at gaiasur.com.ar>
|
|
>... proud to be a PSA member <http://www.python.org/psa>
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|