Re: VBscript to set the inherit permissions in registry
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Jun 2006 19:48:14 -0500
Joe wrote:
We would like to set the "allow inheritable permissions from parent to
propogate to this object" on a workstation from a script. Is there a
method to do this?
I realize the end user will have to be logged & have the necessary
permission to modify the setting. But I am having a difficult time
finding a way to set this specific setting.
Thank you for your assistance.
~Joe
I have scripts to read and write this setting for Active Directory objects,
but I was not aware of this setting for local machine resources. Where do
you see the setting?
If you mean how to set this for AD objects, here is a sample:
===================
' VBScript program to toggle "allow inheritable permissions from
' parent to propagate to this object" on the Security tab of the object.
Option Explicit
Const SE_DACL_PROTECTED = &H1000
Dim objUser, objNtSecurityDescriptor, intNtSecurityDescriptorControl
' Distinguished Name of object hard coded.
Set objUser = GetObject("LDAP://cn=TestUser,ou=Sales,dc=MyDomain,dc=com")
' Retrieve security descriptor object for this object.
Set objNtSecurityDescriptor = objUser.Get("ntSecurityDescriptor")
' Retrieve control settings.
intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control
' Toggle the bit for "allow inheritable permissions".
intNtSecurityDescriptorControl = intNtSecurityDescriptorControl _
Xor SE_DACL_PROTECTED
' Save control settings in the security descriptor object.
objNtSecurityDescriptor.Control = intNtSecurityDescriptorControl
' Save the security descriptor object.
objUser.Put "ntSecurityDescriptor", objNtSecurityDescriptor
' Update the user object.
objUser.SetInfo
Wscript.Echo "Done"
=================
As with all flag settings, you "And" the property with the appropriate bit
mask (SE_DACL_PROTECTED in this case) to test if it is set - any non-zero
result means the flag is set. You "Or" with the bit mask to set the flag,
you "Xor" with the bit mask to toggle. The above toggles. If you want to set
the flag, you probably should "Or". The procedure to un-set would be to
first test with "And", and if the flag is set, toggle with "Xor".
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
.
- Follow-Ups:
- References:
- VBscript to set the inherit permissions in registry
- From: google
- VBscript to set the inherit permissions in registry
- Prev by Date: Re: Windows Support for VBScript
- Next by Date: Re: Windows Support for VBScript
- Previous by thread: VBscript to set the inherit permissions in registry
- Next by thread: Re: VBscript to set the inherit permissions in registry
- Index(es):
Relevant Pages
|
|