<head>
<title>User Information</title>
<HTA:APPLICATION
APPLICATIONNAME="User Information"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' Global variables
Dim arrRows
Sub Window_OnLoad
intWidth = 800
intHeight = 800
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
btnFirstEvent.Disabled = True
btnPreviousEvent.Disabled = True
btnNextEvent.Disabled = True
btnLastEvent.Disabled = True
btnFirstEvent.Style.Visibility = "Hidden"
btnPreviousEvent.Style.Visibility = "Hidden"
btnNextEvent.Style.Visibility = "Hidden"
btnLastEvent.Style.Visibility = "Hidden"
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
ElseIf Window.Event.KeyCode = 27 Then
Clear_Form
End If
End Sub
Sub Clear_Form
txt_seatno.Value = ""
txt_seatno.style.backgroundColor="#FFFFFF"
txt_seatno.Disabled = False
txt_extensionno.Value = ""
txt_extensionno.style.backgroundColor="#FFFFFF"
txt_extensionno.Disabled = False
txt_empid.Value = ""
txt_empid.style.backgroundColor="#FFFFFF"
txt_empid.Disabled = False
txt_department.Value = ""
txt_department.style.backgroundColor="#FFFFFF"
txt_department.Disabled = False
txt_designation.Value = ""
txt_designation.style.backgroundColor="#FFFFFF"
txt_designation.Disabled = False
txt_name.Value = ""
txt_name.style.backgroundColor="#FFFFFF"
txt_name.Disabled = False
txt_loginname.Value = ""
txt_loginname.style.backgroundColor="#FFFFFF"
txt_loginname.Disabled = False
txt_email.Value = ""
txt_email.style.backgroundColor="#FFFFFF"
txt_email.Disabled = False
txt_notes.Value = ""
txt_notes.style.backgroundColor="#FFFFFF"
txt_notes.Disabled = False
txt_mobileno.Value = ""
txt_mobileno.style.backgroundColor="#FFFFFF"
txt_mobileno.Disabled = False
txt_company.Value = ""
txt_company.style.backgroundColor="#FFFFFF"
txt_company.Disabled = False
txt_address.Value = ""
txt_address.style.backgroundColor="#FFFFFF"
txt_address.Disabled = False
txt_city.Value = ""
txt_city.style.backgroundColor="#FFFFFF"
txt_city.Disabled = False
txt_state.Value = ""
txt_state.style.backgroundColor="#FFFFFF"
txt_state.Disabled = False
txt_zipcode.Value = ""
txt_zipcode.style.backgroundColor="#FFFFFF"
txt_zipcode.Disabled = False
txt_country.Value = ""
txt_country.style.backgroundColor="#FFFFFF"
txt_country.Disabled = False
txt_homephone.Value = ""
txt_homephone.style.backgroundColor="#FFFFFF"
txt_homephone.Disabled = False
btnFirstEvent.Style.Visibility = "Hidden"
btnPreviousEvent.Style.Visibility = "Hidden"
btnNextEvent.Style.Visibility = "Hidden"
btnLastEvent.Style.Visibility = "Hidden"
span_currentrecord.InnerHTML = "0"
span_totalrecords.InnerHTML = "0"
End Sub
Sub Submit_Form
arrFields = Array(_
"txt_seatno", _
"txt_extensionno", _
"txt_empid", _
"txt_department", _
"txt_designation", _
"txt_name", _
"txt_loginname", _
"txt_email", _
"txt_notes", _
"txt_mobileno", _
"txt_company", _
"txt_address", _
"txt_city", _
"txt_state", _
"txt_zipcode", _
"txt_country", _
"txt_homephone" _
)
boolValid = False
For Each strField In arrFields
If Eval(strField & ".Disabled") = True Then
boolValid = True
End If
If Eval(strField & ".Disabled") = False Then
strCurrentField = strField
End If
Next
If boolValid = False Then strCurrentField = "INVALID"
Select Case strCurrentField
Case "txt_seatno"
If txt_seatno.Value = "" Then
strSearchField = "(physicalDeliveryOfficeName=*)"
Else
strSearchField = "(physicalDeliveryOfficeName=*" & txt_seatno.Value & "*)"
End If
Case "txt_extensionno"
If txt_extensionno.Value = "" Then
strSearchField = "(telephoneNumber=*)"
Else
strSearchField = "(telephoneNumber=*" & txt_extensionno.Value & "*)"
End If
Case "txt_empid"
If txt_empid.Value = "" Then
strSearchField = "(description=*)"
Else
strSearchField = "(description=*" & txt_empid.Value & "*)"
End If
Case "txt_department"
If txt_department.Value = "" Then
strSearchField = "(department=*)"
Else
strSearchField = "(department=*" & txt_department.Value & "*)"
End If
Case "txt_designation"
If txt_designation.Value = "" Then
strSearchField = "(title=*)"
Else
strSearchField = "(title=*" & txt_designation.Value & "*)"
End If
Case "txt_name"
If txt_name.Value = "" Then
strSearchField = "(cn=*)"
Else
strSearchField = "(cn=*" & txt_name.Value & "*)"
End If
Case "txt_loginname"
If txt_loginname.Value = "" Then
strSearchField = "(samAccountName=*)"
Else
strSearchField = "(samAccountName=*" & txt_loginname.Value & "*)"
End If
Case "txt_email"
If txt_email.Value = "" Then
strSearchField = "(mail=*)"
Else
strSearchField = "(mail=*" & txt_email.Value & "*)"
End If
Case "txt_notes"
If txt_notes.Value = "" Then
strSearchField = "(info=*)"
Else
strSearchField = "(info=*" & txt_notes.Value & "*)"
End If
Case "txt_mobileno"
If txt_mobileno.Value = "" Then
strSearchField = "(mobile=*)"
Else
strSearchField = "(mobile=*" & txt_mobileno.Value & "*)"
End If
Case "txt_company"
If txt_company.Value = "" Then
strSearchField = "(company=*)"
Else
strSearchField = "(company=*" & txt_company.Value & "*)"
End If
Case "txt_address"
If txt_address.Value = "" Then
strSearchField = "(streetAddress=*)"
Else
strSearchField = "(streetAddress=*" & txt_address.Value & "*)"
End If
Case "txt_city"
If txt_city.Value = "" Then
strSearchField = "(l=*)"
Else
strSearchField = "(l=*" & txt_city.Value & "*)"
End If
Case "txt_state"
If txt_state.Value = "" Then
strSearchField = "(st=*)"
Else
strSearchField = "(st=*" & txt_state.Value & "*)"
End If
Case "txt_zipcode"
If txt_zipcode.Value = "" Then
strSearchField = "(postalCode=*)"
Else
strSearchField = "(postalCode=*" & txt_zipcode.Value & "*)"
End If
Case "txt_country"
If txt_country.Value = "" Then
strSearchField = "(c=*)"
Else
strSearchField = "(c=*" & txt_country.Value & "*)"
End If
Case "txt_homephone"
If txt_homephone.Value = "" Then
strSearchField = "(homePhone=*)"
Else
strSearchField = "(homePhone=*" & txt_homephone.Value & "*)"
End If
Case Else
strSearchField = "INVALID"
End Select
Clear_Form
If strSearchField <> "INVALID" Then
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)" & strSearchField & ")"
'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "physicalDeliveryOfficeName,TelephoneNumber,description,Department,Title,cn,samAccountName,mail,Info,Mobile,company,streetAddress,l,st,postalCode,c,homePhone"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset.
strDetails = ""
If Not adoRecordset.EOF Then
Do Until adoRecordset.EOF
If strDetails = "" Then
strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
"|TD|" & adoRecordset.Fields("TelephoneNumber").Value
If IsNull(adoRecordset.Fields("Description").Value) = False Then
strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
Else
strDetails = strDetails & "|TD|"
End If
strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
"|TD|" & adoRecordset.Fields("Department").Value &_
"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
"|TD|" & adoRecordset.Fields("samAccountName").Value &_
"|TD|" & adoRecordset.Fields("mail").Value
If IsNull(adoRecordset.Fields("Info").Value) = False Then
strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name - ", "")
Else
strDetails = strDetails & "|TD|"
End If
strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
"|TD|" & adoRecordset.Fields("company").Value &_
"|TD|" & adoRecordset.Fields("streetAddress").Value &_
"|TD|" & adoRecordset.Fields("l").Value &_
"|TD|" & adoRecordset.Fields("st").Value &_
"|TD|" & adoRecordset.Fields("postalCode").Value &_
"|TD|" & adoRecordset.Fields("c").Value &_
"|TD|" & adoRecordset.Fields("homePhone").Value
Else
strDetails = strDetails & "|TR|" & adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
"|TD|" & adoRecordset.Fields("TelephoneNumber").Value
If IsNull(adoRecordset.Fields("Description").Value) = False Then
strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
Else
strDetails = strDetails & "|TD|"
End If
strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
"|TD|" & adoRecordset.Fields("Department").Value &_
"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
"|TD|" & adoRecordset.Fields("samAccountName").Value &_
"|TD|" & adoRecordset.Fields("mail").Value
If IsNull(adoRecordset.Fields("Info").Value) = False Then
strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name - ", "")
Else
strDetails = strDetails & "|TD|"
End If
strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
"|TD|" & adoRecordset.Fields("company").Value &_
"|TD|" & adoRecordset.Fields("streetAddress").Value &_
"|TD|" & adoRecordset.Fields("l").Value &_
"|TD|" & adoRecordset.Fields("st").Value &_
"|TD|" & adoRecordset.Fields("postalCode").Value &_
"|TD|" & adoRecordset.Fields("c").Value &_
"|TD|" & adoRecordset.Fields("homePhone").Value
End If
adoRecordset.MoveNext
Loop
Else
MsgBox "No records were found"
End If
' Clean up.
adoRecordset.Close
Set adoRecordset = Nothing
adoConnection.Close
If strDetails <> "" Then
arrRows = ""
arrRows = Split(strDetails, "|TR|")
If UBound(arrRows) < 0 Then
span_currentrecord.InnerHTML = "0"
span_totalrecords.InnerHTML = "0"
Else
arrData = Split(arrRows(0), "|TD|")
txt_seatno.Value = arrData(0)
txt_extensionno.Value = arrData(1)
txt_empid.Value = arrData(2)
txt_department.Value = arrData(3)
txt_designation.Value = arrData(4)
txt_name.Value = arrData(5)
txt_loginname.Value = arrData(6)
txt_email.Value = arrData(7)
txt_notes.Value = arrData(8)
txt_mobileno.Value = arrData(9)
txt_company.Value = arrData(10)
txt_address.Value = arrData(11)
txt_city.Value = arrData(12)
txt_state.Value = arrData(13)
txt_zipcode.Value = arrData(14)
txt_country.Value = arrData(15)
txt_homephone.Value = arrData(16)
span_currentrecord.InnerHTML = "1"
span_totalrecords.InnerHTML = UBound(arrRows) + 1
End If
Else
span_currentrecord.InnerHTML = "0"
span_totalrecords.InnerHTML = "0"
End If
If strDetails = "" Then
btnFirstEvent.Disabled = True
btnPreviousEvent.Disabled = True
btnNextEvent.Disabled = True
btnLastEvent.Disabled = True
btnFirstEvent.Style.Visibility = "Hidden"
btnPreviousEvent.Style.Visibility = "Hidden"
btnNextEvent.Style.Visibility = "Hidden"
btnLastEvent.Style.Visibility = "Hidden"
ElseIf UBound(arrRows) = 0 Then
btnFirstEvent.Disabled = True
btnPreviousEvent.Disabled = True
btnNextEvent.Disabled = True
btnLastEvent.Disabled = True
btnFirstEvent.Style.Visibility = "Hidden"
btnPreviousEvent.Style.Visibility = "Hidden"
btnNextEvent.Style.Visibility = "Hidden"
btnLastEvent.Style.Visibility = "Hidden"
Else
btnFirstEvent.Disabled = False
btnPreviousEvent.Disabled = False
btnNextEvent.Disabled = False
btnLastEvent.Disabled = False
btnFirstEvent.Style.Visibility = "Visible"
btnPreviousEvent.Style.Visibility = "Visible"
btnNextEvent.Style.Visibility = "Visible"
btnLastEvent.Style.Visibility = "Visible"
End If
Else
MsgBox "Please type a search request into one of the fields, then click Submit."
End If
End Sub
Sub Get_Event
arrData = Split(arrRows(span_currentrecord.InnerHTML - 1), "|TD|")
txt_seatno.Value = arrData(0)
txt_extensionno.Value = arrData(1)
txt_empid.Value = arrData(2)
txt_department.Value = arrData(3)
txt_designation.Value = arrData(4)
txt_name.Value = arrData(5)
txt_loginname.Value = arrData(6)
txt_email.Value = arrData(7)
txt_notes.Value = arrData(8)
txt_mobileno.Value = arrData(9)
txt_company.Value = arrData(10)
txt_address.Value = arrData(11)
txt_city.Value = arrData(12)
txt_state.Value = arrData(13)
txt_zipcode.Value = arrData(14)
txt_country.Value = arrData(15)
txt_homephone.Value = arrData(16)
End Sub
Sub First_Event
If IsArray(arrRows) = False Then
MsgBox "There are no records to display."
Else
If span_totalrecords.InnerHTML < 1 Then
MsgBox "There are no records to display"
ElseIf span_currentrecord.InnerHTML = 1 Then
MsgBox "You are already viewing the first record."
Else
span_currentrecord.InnerHTML = 1
Get_Event
End If
End If
End Sub
Sub Previous_Event
If IsArray(arrRows) = False Then
MsgBox "There are no records to display."
Else
If span_currentrecord.InnerHTML > 1 Then
span_currentrecord.InnerHTML = span_currentrecord.InnerHTML - 1
Get_Event
ElseIf span_currentrecord.InnerHTML = 1 Then
MsgBox "You are already viewing the first record."
Else
MsgBox "There are no records to display"
End If
End If
End Sub
Sub Next_Event
If IsArray(arrRows) = False Then
MsgBox "There are no records to display."
Else
If span_totalrecords.InnerHTML = 0 Then
MsgBox "There are no records for to display"
ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
MsgBox "You are already viewing the last record."
Else
span_currentrecord.InnerHTML = span_currentrecord.InnerHTML + 1
Get_Event
End If
End If
End Sub
Sub Last_Event
If IsArray(arrRows) = False Then
MsgBox "There are no records to display."
Else
If span_totalrecords.InnerHTML = 0 Then
MsgBox "There are no records to display"
ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
MsgBox "You are already viewing the last record."
Else
span_currentrecord.InnerHTML = span_totalrecords.InnerHTML
Get_Event
End If
End If
End Sub
Sub Detect_Search_Field(strCurrentField)
arrFields = Array(_
"txt_seatno", _
"txt_extensionno", _
"txt_empid", _
"txt_department", _
"txt_designation", _
"txt_name", _
"txt_loginname", _
"txt_email", _
"txt_notes", _
"txt_mobileno", _
"txt_company", _
"txt_address", _
"txt_city", _
"txt_state", _
"txt_zipcode", _
"txt_country", _
"txt_homephone" _
)
For Each strField In arrFields
If LCase(strField) <> LCase(strCurrentField) Then
Execute strField & ".style.backgroundColor=""#D3D3D3"""
Execute strField & ".Disabled = True"
End If
Next
End Sub
Sub RunScript
strAnswer = window.prompt("Please enter the Location to save.", "C:\HTAResults.csv")
If IsNull(strAnswer) Then
Msgbox "You clicked the Cancel button"
Else
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strAnswer) = True Then
Set objFile = objFSO.OpenTextFile(strAnswer, 8, False)
Else
Set objFile = objFSO.CreateTextFile(strAnswer, True)
objFile.Write """Seat No"",""Extension"",""Emp ID"",""Department"",""Designation"",""User Name"",""Login Name"",""Email Address"",""Computer"",""Mobile"",""Company"",""Address"",""City"",""State"",""Zip Code"",""Country"",""Home Phone"""
End If
For intRow = LBound(arrRows) To UBound(arrRows)
arrData = Split(arrRows(intRow), "|TD|")
objFile.Write VbCrLf & """" & arrData(0) & """,""" & arrData(1) & """,""" & arrData(2) & """,""" & arrData(3) & _
""",""" & arrData(4) & """,""" & arrData(5) & """,""" & arrData(6) & """,""" & arrData(7) & _
""",""" & arrData(8) & """,""" & arrData(9) & """,""" & arrData(10) & """,""" & arrData(11) & _
""",""" & arrData(12) & """,""" & arrData(13) & """,""" & arrData(14) & """,""" & arrData(15) & _
""",""" & arrData(16) & """"
Next
objFile.Close
MsgBox "Saved."
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center' colspan="2">
<h3>User Information</h3><br>
</td>
</tr
<tr>
<td align='center' colspan="2">
<table border="0">
<tr>
<td>
Seat No:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_seatno" name="txt_seatno" onkeypress="vbs:Detect_Search_Field('txt_seatno')">
</td>
</tr>
<tr>
<td>
Extension No:
</td>
<td>
<input type="text" maxlength="25" size="40" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Detect_Search_Field('txt_extensionno')">
</td>
</tr>
<tr>
<td>
Emp ID:
</td>
<td>
<input type="text" maxlength="6" size="10" id="txt_empid" name="txt_empid" onkeypress="vbs:Detect_Search_Field('txt_empid')">
</td>
</tr>
<tr>
<td>
Department:
</td>
<td>
<input type="text" maxlength="30" size="50" id="txt_department" name="txt_department" onkeypress="vbs:Detect_Search_Field('txt_department')">
</td>
</tr>
<tr>
<td>
Designation:
</td>
<td>
<input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Detect_Search_Field('txt_designation')">
</td>
</tr>
<tr>
<td>
User Name:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" onkeypress="vbs:Detect_Search_Field('txt_name')">
</td>
</tr>
<tr>
<td>
Login Name:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" onkeypress="vbs:Detect_Search_Field('txt_loginname')">
</td>
</tr>
<tr>
<td>
Email Address:
</td>
<td>
<input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" onkeypress="vbs:Detect_Search_Field('txt_email')">
</td>
</tr>
<tr>
<td>
Machine Name:
</td>
<td>
<input type="text" maxlength="16" size="20" id="txt_notes" name="txt_notes" onkeypress="vbs:Detect_Search_Field('txt_notes')">
</td>
</tr>
<tr>
<td>
Mobile Number:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_mobileno" name="txt_mobileno" onkeypress="vbs:Detect_Search_Field('txt_mobileno')">
</td>
</tr>
<tr>
<td>
Company:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_company" name="txt_company" onkeypress="vbs:Detect_Search_Field('txt_company')">
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_address" name="txt_address" onkeypress="vbs:Detect_Search_Field('txt_address')">
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_city" name="txt_city" onkeypress="vbs:Detect_Search_Field('txt_city')">
</td>
</tr>
<tr>
<td>
State:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_state" name="txt_state" onkeypress="vbs:Detect_Search_Field('txt_state')">
</td>
</tr>
<tr>
<td>
Zip Code:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_zipcode" name="txt_zipcode" onkeypress="vbs:Detect_Search_Field('txt_zipcode')">
</td>
</tr>
<tr>
<td>
Country:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_country" name="txt_country" onkeypress="vbs:Detect_Search_Field('txt_country')">
  Must search by 2 letter country code
</td>
</tr>
<tr>
<td>
Home Phone:
</td>
<td>
<input type="text" maxlength="14" size="20" id="txt_homephone" name="txt_homephone" onkeypress="vbs:Detect_Search_Field('txt_homephone')">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<br>Showing record 
<span id="span_currentrecord">
0
</span>
 of 
<span id="span_totalrecords">
0
</span>
<br>
<input type='button' value='||< First' name='btnFirstEvent' onClick='vbs:First_Event'>     
<input type='button' value='<< Previous' name='btnPreviousEvent' onClick='vbs:Previous_Event'>     
<input type='button' value='Next >>' name='btnNextEvent' onClick='vbs:Next_Event'>     
<input type='button' value='Last >||' name='btnLastEvent' onClick='vbs:Last_Event'><br><br><br>
<input type='button' value='Clear Form' name='btnClearForm' onClick='vbs:Clear_Form'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
<input id=runbutton class="button" type="button" value="Save to" name="run_button" onClick="Runscript">
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
For this Hta there is no body as such....
Where can i place the line
<table><tr><td align='right'><img src='\images\mylogo.jpg'><
Open in new window