RowaldLaterveer
asked on
Need HTA to kill/reset terminal session or kill process
Hi all!
I am struggeling with the next problem. We have 2 terminal servers, receiving ICA and RDP connections from our workers.
I need to get an HTA build where i can select a user from AD (lastname or username), then the script has to go look on the two servers if the user is active and present me on wich server the user is active. Then i need to have a menu, to reset the users session or to view the users processes and let me select what proces to kill.
I have some code to do the first step (let me select a user from AD), but i don't know from where to go there.
I am struggeling with the next problem. We have 2 terminal servers, receiving ICA and RDP connections from our workers.
I need to get an HTA build where i can select a user from AD (lastname or username), then the script has to go look on the two servers if the user is active and present me on wich server the user is active. Then i need to have a menu, to reset the users session or to view the users processes and let me select what proces to kill.
I have some code to do the first step (let me select a user from AD), but i don't know from where to go there.
Sub Start_Search
If txtSearchText.Value <> "" Then
For Each objOption In lstUsers.Options
lstUsers.Remove(objOption.Index)
Next
' Determine DNS domain name.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use ADO to search Active Directory.
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://" & strDNSDomain & ">"
'Change this to the Netbios Domain Name
Set objNetwork = CreateObject("WScript.Network")
strNetBiOSDomain = objNetwork.UserDomain
If optSearchType(0).Checked = True Then
' Username is selected
strFilter = "(&(objectCategory=person)(objectClass=user)(samAccountName=" & txtSearchText.Value & "))"
Else
' Last name is selected
strFilter = "(&(objectCategory=person)(objectClass=user)(sn=" & txtSearchText.Value & "))"
End If
strAttributes = "givenName,sn,sAMAccountName,adsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Set objRecordSetArr = objCommand.Execute
If objRecordSet.EOF Then
MsgBox "Er zijn geen gebruikers gevonden."
Else
While Not objRecordSet.EOF
Set objOption = Document.CreateElement("OPTION")
objOption.Text = objRecordSet.Fields("givenName").Value & " " & objRecordSet.Fields("sn").Value
objOption.Value = objRecordSet.Fields("adsPath").Value
lstUsers.Add objOption
objRecordSet.MoveNext
Wend
End If
Else
MsgBox "Voer een zoekterm in."
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.