Change directory permission under windows

S

__schronos__

Hi.

I would like to add users with full control access to a directory. I
can do it to a file in the following way:

info=win32security.DACL_SECURITY_INFORMATION
sd=win32security.GetFileSecurity(DIR, info)
acl=sd.GetSecurityDescriptorDacl()
sidUser=win32security.LookupAccountName(None,USER)[0]
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
sd.SetSecurityDescriptorDacl(1, acl, 0)
win32security.SetFileSecurity(dir, info, sd)

and it work correctly, but if I try to do the same to a directory only
the "special permission" checkbox is checked and this is not useful to
me because I need a "full control" so that files under the directory
can inheritage the directory rigths.

Can anybody help me

Thank's
 
R

Roger Upole

__schronos__ said:
Hi.

I would like to add users with full control access to a directory. I
can do it to a file in the following way:

info=win32security.DACL_SECURITY_INFORMATION
sd=win32security.GetFileSecurity(DIR, info)
acl=sd.GetSecurityDescriptorDacl()
sidUser=win32security.LookupAccountName(None,USER)[0]
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
sd.SetSecurityDescriptorDacl(1, acl, 0)
win32security.SetFileSecurity(dir, info, sd)

and it work correctly, but if I try to do the same to a directory only
the "special permission" checkbox is checked and this is not useful to
me because I need a "full control" so that files under the directory
can inheritage the directory rigths.

Can anybody help me

Thank's
AddAccessAllowedAce doesn't have a parm for inheritance flags.
Try AddAccessAllowedAceEx instead:

acl.AddAccessAllowedAceEx(win32security.ACL_REVISION_DS,
win32security.OBJECT_INHERIT_ACE|win32security.CONTAINER_INHERIT_ACE,
win32file.FILE_ALL_ACCESS, sidUser)

Roger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top