| |
ybotspawn
Posts: 2
Score: 0
Joined: 5/18/2008
Status: offline
|
Hey everyone, im obviously new here but i have a problem. I made a script that sets the active directory security setting that enable this setting for users, but can't seem to modify it to do the same for computers. I continually get a contraint violation has occured on line 38, char 1. ANy advice would be great!! ! THanks in advance!!! 'enableperminheritance.vbs 'Set strOUpath variable to match the 'target OU in your domain strOUpath = "OU=testinherit,OU=Test,OU=Workstations,OU=ybotspawn,OU=buildings,DC=oz,DC=kiamoko,DC=org" Const SE_DACL_PROTECTED = 0 'enables inheritance 'Connect to OU in Active Directory set objConn = createObject("ADODB.Connection") set objCommand = createObject("ADODB.Command") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConn strUsrFil = "<LDAP://" & strOUpath & ">;(&(objectCategory=person)(objectClass=Computer))" objCommand.CommandText = strUsrFil & ";Name;subtree" 'wscript.echo strUsrFil & ";sAMAccountName;subtree" objCommand.Properties("Page Size") = 100 objCommand.Properties("Timeout") = 30 objCommand.Properties("Cache Results") = False Set objComputerRecords = objCommand.Execute intComputerCount = 0 'Computer object counter ' Enable Permissions inheritance for each Computer Do Until objComputerRecords.EOF intComputerCount = intComputerCount + 1 strComputer = objComputerRecords.Fields("Name").Value 'wscript.echo "LDAP://cn=" & strComputer & "," & strOuPath strComputer=replace(strComputer, ",", "\,") strComputer=replace(strComputer, "/", "\/") 'set objComputer = GetObject ("LDAP://cn=" & replace(strComputer, ",", "\,") & "," & strOuPath) set objComputer = GetObject ("LDAP://cn=" & strComputer & "," & strOuPath) Set objNTSec = objComputer.Get("nTSecurityDescriptor") intNTSecDes = objNTSec.Control intNTSecDes = intNTSecDes And SE_DACL_PROTECTED objNTSec.Control = intNTSecDes 'objComputer.Put "nTSecurityDescriptor", objNTSec objComputer.Put("ntSecurityDescriptor"), objNTSec 'objComputer.SetInfo objComputerRecords.MoveNext Loop ' Output the number of records changed ' Note that the permissions inheritance flag is ' set on all Computers in the OU, regardless of whether ' or not it was already set. wscript.echo("Enabled Permissions Inheritance for " &_ intComputerCount & " Computers in the OU " & strOUpath)
|
|