DUnnerstall
Technical User
I am attempting to query ADSI for all of the computers in an OU and get the OU, Domain and Suffix from an HTA form. I have this code:
<html>
<head>
<title>NumLock Reg Change</title>
<hta:application>
<script language="vbscript">
window.resizeTo 500,400
Sub RunScript
'On Error Resume Next
OU=”cn=document.Forms(0).elements("OU").value”
'Domain="dc=document.Forms(0).elements("Domain").value"
'Suffix="dc=document.Forms(0).elements("Suffix").value"
' Read list of hosts from an Active Directory container with ADSI and store them in an array
Set colOU = GetObject("LDAP://" & OU & "," & Domain & "," & Suffix)
colOU.Filter = Array("Computer")
For Each objComputer in colOU
strComputer = objComputer.CN
Next
End Sub
</script>
</head>
<body>
<form>
Enter the OU where computers are:
<br><input type=text name=OU tabindex=1>
<br>Enter the Domain Name with no suffix:
<br><input type=text name=Domain>
<br>Enter the suffix:
<br><input type=text name=Suffix>
<br><input type=button language="vbscript" value="OK"
onclick="RunScript">
</form>
<script language=vbscript>
document.Forms(0).elements("OU").focus
</script>
</body>
</html>
The problem is where the variables are assigned the values from the HTA form:
OU=”cn=document.Forms(0).elements("OU").value”
'Domain="dc=document.Forms(0).elements("Domain").value"
'Suffix="dc=document.Forms(0).elements("Suffix").value"
This does not work. This causes a Run Time Error (Expected End Of Statement). It seems the extra sets of quotes are hosing the works. Does any one know of another method?
<html>
<head>
<title>NumLock Reg Change</title>
<hta:application>
<script language="vbscript">
window.resizeTo 500,400
Sub RunScript
'On Error Resume Next
OU=”cn=document.Forms(0).elements("OU").value”
'Domain="dc=document.Forms(0).elements("Domain").value"
'Suffix="dc=document.Forms(0).elements("Suffix").value"
' Read list of hosts from an Active Directory container with ADSI and store them in an array
Set colOU = GetObject("LDAP://" & OU & "," & Domain & "," & Suffix)
colOU.Filter = Array("Computer")
For Each objComputer in colOU
strComputer = objComputer.CN
Next
End Sub
</script>
</head>
<body>
<form>
Enter the OU where computers are:
<br><input type=text name=OU tabindex=1>
<br>Enter the Domain Name with no suffix:
<br><input type=text name=Domain>
<br>Enter the suffix:
<br><input type=text name=Suffix>
<br><input type=button language="vbscript" value="OK"
onclick="RunScript">
</form>
<script language=vbscript>
document.Forms(0).elements("OU").focus
</script>
</body>
</html>
The problem is where the variables are assigned the values from the HTA form:
OU=”cn=document.Forms(0).elements("OU").value”
'Domain="dc=document.Forms(0).elements("Domain").value"
'Suffix="dc=document.Forms(0).elements("Suffix").value"
This does not work. This causes a Run Time Error (Expected End Of Statement). It seems the extra sets of quotes are hosing the works. Does any one know of another method?