Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputing to script AD principals from HTA

Status
Not open for further replies.

DUnnerstall

Technical User
Apr 4, 2000
13
0
0
US
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?




 
You may try this:
OU="cn=" & document.Forms(0).elements("OU").value

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top