I have a HTA script for group membership information retrieval. I just started to learning HTA and tried my best to modify to fir my requirement <<attached file>>.
*My Scripts does the below:* I have a static OU Named OU=MyDepartment,DC=org,DC=dev,DC=lab,DC=net And all the Required / targeted AD groups will be located in above OU called MyDepartment . >From HTA Script I can select required AD group Name. When I executed the HTA file it will Update “*adminDescription”* attribute in Active Directory to something I have hard coded in the script, and it works. However, am looking to update based on text box value which user can enter *a value.* *In the script below lines are executing to update required AD attribute i.e., “adminDescription” to “Scientist021”.* Const ADS_PROPERTY_UPDATE = 2 Set objGroup = GetObject("LDAP://" & lst_groupfilter.Value) objGroup.Put "adminDescription", "Scientist021" objGroup.SetInfo Currently I have configured to update this value when click on Get Members Button (I even wanted to rename this to button name to “UpdateValues”. I stuck at this place, I wanted to put value as “Scientist021” or whatever in the text which User can type in a text box [image: Inline image 1] Can anyone help me in this please. -- Thanks, Hun ED
<Html> <Head> <Title>Set Group AdminDescription</Title> <HTA:Application Caption = Yes Border = Thick ShowInTaskBar = Yes SingleInstance = Yes MaximizeButton = Yes MinimizeButton = Yes> <script Language = VBScript> Const ADS_PROPERTY_UPDATE = 2 Sub Window_OnLoad intWidth = 800 intHeight = 600 Me.ResizeTo intWidth, intHeight Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2)) lst_members.Style.Width = 500 'Set objRootDSE = GetObject("LDAP://RootDSE") Set objRootDSE = GetObject("LDAP://OU=MyDepartment,DC=org,DC=dev,DC=lab,DC=net") strBaseConnString = objRootDSE.Get("distinguishedName") Set objOULevel = GetObject("LDAP://" & strBaseConnString) EnumerateGroups strBaseConnString Show_Group_Selection End Sub Sub EnumerateGroups(strDNSDomain) Const ADS_SCOPE_SUBTREE = 2 Const adVarChar = 200 Const MaxCharacters = 255 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = "SELECT Name, distinguishedName FROM 'LDAP://" & strDNSDomain & "' WHERE objectClass='group'" Set objRecordSet = objCommand.Execute Set objDataList = CreateObject("ADOR.Recordset") objDataList.Fields.Append "name", adVarChar, MaxCharacters objDataList.Fields.Append "distinguishedName", adVarChar, MaxCharacters objDataList.Open While Not objRecordSet.EOF objDataList.AddNew objDataList("name") = objRecordSet.Fields("name").Value objDataList("distinguishedName") = objRecordSet.Fields("distinguishedName").Value objDataList.Update objRecordSet.MoveNext Wend objRecordSet.Close objDataList.Sort = "name" objDataList.MoveFirst While Not objDataList.EOF Set objActiveOption = Document.CreateElement("OPTION") objActiveOption.Text = objDataList.Fields("name").Value objActiveOption.Value = objDataList.Fields("distinguishedName").Value lst_GroupFilter.Add objActiveOption objDataList.MoveNext Wend objDataList.Close End Sub Sub Show_Group_Selection span_GroupFilter.InnerHTML = lst_GroupFilter.Value End Sub Sub Default_Buttons If Window.Event.KeyCode = 13 Then btn_run.Click End If End Sub Sub Exit_HTA Window.Close End Sub Sub Get_Members ' Const adVarChar = 200 ' Const MaxCharacters = 255 Const ADS_PROPERTY_UPDATE = 2 Set objGroup = GetObject("LDAP://" & lst_groupfilter.Value) objGroup.Put "adminDescription", "Scientist021" objGroup.SetInfo ' Clear_Members ' Set objGroup = GetObject("LDAP://" & lst_groupfilter.Value) ' Set objDataList = CreateObject("ADOR.Recordset") ' objDataList.Fields.Append "name", adVarChar, MaxCharacters ' objDataList.Fields.Append "distinguishedName", adVarChar, MaxCharacters ' objDataList.Open ' For Each objObject In objGroup.Members ' objDataList.AddNew ' objDataList("name") = objObject.cn ' objDataList("distinguishedName") = objObject.distinguishedName ' objDataList.Update ' Next ' objDataList.Sort = "name" ' If Not objDataList.BOF Then objDataList.MoveFirst ' While Not objDataList.EOF ' Set objMember = Document.CreateElement("OPTION") ' objMember.Text = objDataList.Fields("name").Value ' objMember.Value = objDataList.Fields("distinguishedName").Value ' lst_members.Add objMember ' objDataList.MoveNext ' Wend ' objDataList.Close End Sub Sub ExporT_To_TXT If Mid(document.location, 6, 3) = "///" Then strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 9) Else strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 6) End If strFileName = Left(strHTAPath, InStrRev(strHTAPath, "\")) & lst_GroupFilter.Item(lst_GroupFilter.SelectedIndex).Text & ".txt" strFileName = InputBox("Enter file name to save as:", "Save As", strFileName) If strFileName <> "" Then Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile(strFileName, True) objFile.WriteLine "Group Distinguished Name: " & lst_groupfilter.Value For Each objOption In lst_members objFile.WriteLine objOption.Text Next objFile.Close MsgBox "File saved." End If End Sub </script> <body style="background-color:#B0C4DE;" onkeypress='vbs:Default_Buttons'> <table height="90%" width= "90%" border="0" align="center"> <tr> <td align="center" colspan="2"> <h2>Set Group AdminDescription</h2> </td> </tr> <tr> <td> <b>Group Filter:</b> </td> <td> <select size='1' name='lst_GroupFilter' onChange='vbs:Show_Group_Selection'> </select> </td> </tr> <tr> <td colspan=2> <b>Group Selected:</b>   <span id='span_GroupFilter'></span> </td> </tr> <tr> <td> <b>Members:</b> </td> <td> <select size='8' name='lst_members'> </select> </td> </tr> </table> <table width= "90%" border="0" align="center"> <tr align="center"> <td> <button name="btn_run" id="btn_run" accessKey="G" onclick="vbs:Get_Members"><u>G</u>et Members</button> </td> <td> <button name="btn_export" id="btn_export" accessKey="E" onclick="vbs:Export_To_TXT"><u>E</u>xport to TXT</button> </td> <td> <button name="btn_exit" id="btn_exit" accessKey="x" onclick="vbs:Exit_HTA">E<u>x</u>it</button> </td> </tr> </table> </body> </head> </html>