I'm trying to create an HTA that will move users from one group to another. I can move all of the users without any problem, but I can't figure out how to handle specific users. I have a feeling that my handling of the select list is my primary issue at this point. I can build the list, but I'm not sure how to send the selections back to a subroutine. Once I figure that out, I can start working on the sub used to move them.
Can anyone give me a nudge in the right direction?
This is what I have so far:
Can anyone give me a nudge in the right direction?
This is what I have so far:
Code:
<head>
<title>Terminal Server Access Control</title>
<HTA:APPLICATION
APPLICATIONNAME="Allow or deny Terminal Server access"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
<style type="text/css">
#AllowedColumn {
border: 1px solid black;
float:left;
height: auto;
overflow: auto;
padding:10px;""
width: 40%;
}
#AllowedColumn h2 {color:green;}
#AllowedDiv {
border: 0px solid black;
float:left;
height: auto;
overflow: auto;
padding:10px;
width: auto;
}
#DataArea {
padding:10px;
}
#DeniedColumn {
border: 1px solid black;
float:left;
height: auto;
overflow: auto;
padding:10px;
width: 40%;
}
#DeniedColumn h2 {color:red;}
#DeniedDiv {
border: 0px solid black;
float:left;
height: auto;
overflow: auto;
padding:10px;
width: auto;
}
#CenterDiv {
border: 0px solid black;
float:left;
width: 10%;
height: auto;
overflow: auto;
padding-top:100px;
}
</style>
</head>
<script language="VBScript">
Option Explicit
Dim AllowGroup,arrayAllowed,arrayDenied,DenyGroup,strAllowList,strDenyList,strUser,User,UserName
Set AllowGroup = GetObject("WinNT://" & "Accounting" & "/" & "V2 Users" & ",group")
Set DenyGroup = GetObject("WinNT://" & "Accounting" & "/" & "Deny TS Logon" & ",group")
Set arrayAllowed = CreateObject( "System.Collections.ArrayList" )
Set arrayDenied = CreateObject( "System.Collections.ArrayList" )
Sub Allow_TSLogon
For Each UserName in DenyGroup.Members
Set User = GetObject("WinNT://" & "Accounting" & "/" & UserName.Name & ",user")
'###Remove from "Deny Ts Logon" group###
DenyGroup.Remove(User.ADsPath)
DenyGroup.SetInfo
'###Add user to "V2 Users" group###
AllowGroup.Add(User.ADsPath)
AllowGroup.SetInfo
Next
Call List_Allowed
Call List_Denied
End Sub
Sub Deny_TSLogon
For Each UserName in AllowGroup.Members
Set User = GetObject("WinNT://" & "Accounting" & "/" & UserName.Name & ",user")
'###Remove from "V2 Users" group###
AllowGroup.Remove(User.ADsPath)
AllowGroup.SetInfo
'###Add user to "Deny TS Logon" group###
DenyGroup.Add(User.ADsPath)
DenyGroup.SetInfo
Next
Call List_Allowed
Call List_Denied
End Sub
Sub List_Allowed
AllowedDiv.InnerHTML = ""
strAllowList = ""
arrayAllowed.Clear()
For Each UserName in AllowGroup.Members
arrayAllowed.Add UserName.Name
Next
arrayAllowed.Sort
For Each strUser in arrayAllowed
strAllowList = strAllowList + "<option value=" + strUser + ">" + strUser + "</option>"
Next
AllowedDiv.InnerHTML = "<select name=""allowedusers"" multiple=""multiple"" size=""40"">" + strAllowList + "</select>"
End Sub
Sub List_Denied
DeniedDiv.InnerHTML = ""
strDenyList = ""
arrayDenied.Clear()
For Each UserName in DenyGroup.Members
arrayDenied.Add UserName.Name
Next
arrayDenied.Sort
For Each strUser in arrayDenied
strDenyList = strDenyList + "<option value=" + strUser + ">" + strUser + "</option>"
Next
DeniedDiv.InnerHTML = "<select name=""deniedusers"" multiple=""multiple"" size=""40"">" + strDenyList + "</select>"
End Sub
</script>
<body>
<b>Allow or deny access to the server through Terminal Services/Remote Desktop.</b><p>
<b>If you deny access to everyone, only the Administrator account will be able to log in via Remote Desktop.</b><p>
<br /><br />
<div id="DataArea">
<div id="AllowedColumn" align="center">
<h2>Users allowed access to V2</h2>
<div id="AllowedDiv">
<script>List_Allowed</script>
</div>
</div>
<div id="CenterDiv" align="center">
Move all
<br /><br />
<input type="button" value=" << " name="run_button" onClick="Allow_TSLogon">
<br /><br />
<input type="button" value=" >> " name="run_button" onClick="Deny_TSLogon">
<br /><br /><br /><br /><br /><br />
Move Selected
<br /><br />
<input type="button" value=" < " name="run_button" onClick="">
<br /><br />
<input type="button" value=" > " name="run_button" onClick="">
<br /><br />
</div>
<div id="DeniedColumn" align="center">
<h2>Users denied access to V2</h2>
<div id="DeniedDiv">
<script>List_Denied</script>
</div>
</div>
</div>
</body>