|
I am trying to use Kix and ADSI to add a group the ability to join an domain when I create the computer account. I'm creating the computer account via ADSI already but I'm having trouble working with the ACE
I found this VB script on the MS website, but I'm not familiar with VB or Kix enough to translate one to the other.
Can anyone pleaes help?
---VB script from Q222525 '********************************************************************* '* Specify which user or group may activate/join this computer to the '* domain. In this example, "MYDOMAIN" is the domain name and '* "JoeSmith" is the account being given the permission. Note that '* this is the downlevel naming convention used in this example. '*********************************************************************
sUserOrGroup = "MYDOMAIN\joesmith"
'********************************************************************* '* Bind to the Discretionary ACL on the newly created computer account '* and create an Access Control Entry (ACE) that gives the specified '* user or group full control on the machine account '*********************************************************************
Set secDescriptor = oComputer.Get("ntSecurityDescriptor") Set dACL = secDescriptor.DiscretionaryAcl Set ACE = CreateObject("AccessControlEntry")
'********************************************************************* '* An AccessMask of "-1" grants Full Control '*********************************************************************
ACE.AccessMask = -1 ACE.AceType = ADS_ACETYPE_ACCESS_ALLOWED ACE.AceFlags = ADS_ACEFLAG_INHERIT_ACE
'********************************************************************* '* Grant this control to the user or group specified earlier. '*********************************************************************
ACE.Trustee = sUserOrGroup
'********************************************************************* '* Now, add this ACE to the DACL on the machine account '*********************************************************************
dACL.AddAce ACE secDescriptor.DiscretionaryAcl = dACL
'********************************************************************* '* Commit (write) the security changes to the machine account '*********************************************************************
oComputer.Put "ntSecurityDescriptor", Array(secDescriptor) oComputer.SetInfo
|