home *** CD-ROM | disk | FTP | other *** search
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Filename: UserAccounts.vbs
- ' *** ------------------------------------------------------------------------------
- ' *** Description: UserAccounts HTA Script
- ' *** ------------------------------------------------------------------------------
- ' *** Version: 1.0
- ' *** Notes: Used by UserAccounts.hta
- ' *** ------------------------------------------------------------------------------
- ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
- ' *** ------------------------------------------------------------------------------
- ' ***
-
- ' ~~~
- ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
- ' ~~~
- Option Explicit
-
-
- Select Case Window.DialogArguments
- Case "ProfileMgr"
- document.title = L_sManageTitle_TEXT
- Case "Restrictions"
- document.title = L_sRestrictTitle_TEXT
- End Select
-
- ' ~~~ -------------------------------------------------------------------------
- ' ~~~ Declare variables
- ' ~~~ ------------------------------------------------------------------------
- Dim sTool, oUserAccount, colUsers
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Init()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed whilst the spash screen is displayed
- ' *** If this function returns false, the spash screen is not removed
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Init
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim oCol, colImages, oImage
-
- Set oUserAccount = New UserAccounts
- sTool = Window.DialogArguments
-
- Select Case sTool
- Case "ProfileMgr"
- call oUserAccount.ListAccounts("ProfileMgr")
- Case "Restrictions"
- call oUserAccount.ListAccounts("Restrictions")
- End Select
-
- ' ~~~ Get the images collections and make them invisible
- Set colImages = document.body.GetElementsbyTagname("IMG")
-
- For Each oImage in colImages
- oImage.Style.Visibility = "hidden"
- Next
-
- ' ~~~ Get the users collection and highlight the first valid user
- Set colUsers = document.body.GetElementsbyTagname("U")
-
- ' ~~~ If the collection is not null then proceed
- If Not IsNull(colUsers) Then
- For each oCol in colUsers
- oCol.classname = "selectuser"
- document.all("img" & Mid(oCol.id,4)).style.visibility = "visible"
- Call User_mouseover(oCol.id)
- 'document.all("td" & Mid(oCol.id,4)).ScrollIntoView( False)
- Exit For
- Next
- End If
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Load()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed before a wizard page is displayed
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Load
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~ To enable Esc and Enter when the hta is launched
- oBody.disabled = false
- document.body.focus()
-
- End Sub
-
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: UserMain()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on load of the HTA
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub UserMain
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~ Disable the body on load
- oBody.disabled = True
-
- InitialiseAllObjects()
-
- ' ~~~ set up the screen, load controls and pages
- Call Setup()
-
- ' ~~~ call the tool initalization function
- Call Init()
-
- ' ~~~ Call the tool load function
- Call Load()
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Validate()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed before a wizard page is exited
- ' *** If this function returns True The page is ready to close.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Function Validate()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Validate = True
- End Function
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Action()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed when enter key/ok button is pressed
- ' *** ------------------------------------------------------------------------------
- ' ***
- Function Action()
- userenter()
- End Function
-
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: AddUsers(sUserName, bUser, sDisplayName)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed to add the users to display in
- ' *** the Modal dialog
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub AddUsers(sUserName, iUser, sDisplayName)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim sHTML1, sHTML2, oRow, oColumn
-
- Select Case iUser
- Case 0
- sHTML1 = "<img id=""img" + sUserName + """ style=""cursor=hand"" align=""absmiddle"" onclick=""userenter()"" src=""graphics/green_half.gif"">"
- sHTML2 = "<u id=""usr" + sUserName + """ onclick=""User_Select(window.event.srcelement.id)"" onmouseover=""User_mouseover(window.event.srcelement.id)"" style=""cursor:hand;"" class=""unselectuser"">" + sDisplayName + "</u>"
- Case 1
- sHTML1 = ""
- sHTML2 = "<span id=""cln" + sUserName + """ onmouseover=""User_mouseover(window.event.srcelement.id)"" class=""unselectuser"">" + sDisplayName + "</span>"
- Case 2
- sHTML1 = ""
- sHTML2 = "<span id=""adm" + sUserName + """ onmouseover=""User_mouseover(window.event.srcelement.id)"" class=""unselectuser"">" + sDisplayName + "</span>"
- Case 3
- sHTML1 = ""
- sHTML2 = "<span id=""sln" + sUserName + """ onmouseover=""User_mouseover(window.event.srcelement.id)"" class=""unselectuser"">" + sDisplayName + "</span>"
- Case 4
- sHTML1 = "<img id=""img" + sUserName + """ style=""cursor=hand"" align=""absmiddle"" onclick=""userenter()"" src=""graphics/green_half.gif"">"
- sHTML2 = "<u id=""loc" + sUserName + """ onclick=""User_Select(window.event.srcelement.id)"" onmouseover=""User_mouseover(window.event.srcelement.id)"" style=""cursor:hand;"" class=""unselectuser"">" + sDisplayName + "</u>"
- Case 5
- sHTML1 = "<img id=""img" + sUserName + """ style=""cursor=hand"" align=""absmiddle"" onclick=""userenter()"" src=""graphics/green_half.gif"">"
- sHTML2 = "<u id=""dis" + sUserName + """ onclick=""User_Select(window.event.srcelement.id)"" onmouseover=""User_mouseover(window.event.srcelement.id)"" style=""cursor:hand;"" class=""unselectuser"">" + sDisplayName + "</u>"
- Case 6
- sHTML1 = ""
- sHTML2 = "<span id=""nop" + sUserName + """ onmouseover=""User_mouseover(window.event.srcelement.id)"" class=""unselectuser"">" + sDisplayName + "</span>"
- Case 7
- sHTML1 = ""
- sHTML2 = "<span id=""gst" + sUserName + """ onmouseover=""User_mouseover(window.event.srcelement.id)"" class=""unselectuser"">" + sDisplayName + "</span>"
- End Select
-
- ' ~~~ To add columns in to the table
- Set oRow = tUsers.insertrow()
- Set oColumn = oRow.insertcell()
- oColumn.innerHTML = sHTML1
- oColumn.id = "td" + sUserName
- Set oColumn = Nothing
-
- Set oColumn = oRow.insertcell()
- oColumn.innerHTML = sHTML2
- Set oColumn = Nothing
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: User_Select(sUser)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on click of the user name
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub User_Select(sUser)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim sdisplayname
- sdisplayname = document.all(sUser).innerText
- if document.all(sUser).classname = "selectuser" then
- ' ~~~ Extract the user name for Restrictions Tool
- ' ~~~ For ProfileMgr send the user name with the prefix
-
- If Window.DialogArguments = "Restrictions" Then
- sUser = Mid(sUser,4)
- End If
- window.returnValue = Array(sUser,sdisplayname)
- window.close
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: User_mouseover(strUser)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on click of the user name
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub User_mouseover(strUser)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim oCol
-
- Select Case Left(strUser,3)
- Case "usr"
- if window.DialogArguments = "ProfileMgr" Then
- document.all(struser).title = document.all("ManageProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("ManageProfile").innerHTML
- Else
- document.all(struser).title = document.all("RestrictProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("RestrictProfile").innerHTML
- End If
- Case "cln"
- document.all(struser).title = document.all("Currentlogon").innerHTML
- Case "sln"
- document.all(struser).title = document.all("switchlogon").innerHTML
- Case "adm"
- document.all(struser).title = document.all("Admin").innerHTML
- Case "dis"
- if window.DialogArguments = "ProfileMgr" Then
- document.all(struser).title = document.all("DisabledAcc").innerHTML + " " + document.all("ManageProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("DisabledAcc").innerHTML + " " + document.all("ManageProfile").innerHTML
- Else
- document.all(struser).title = document.all("DisabledAcc").innerHTML + " " + document.all("RestrictProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("DisabledAcc").innerHTML + " " + document.all("RestrictProfile").innerHTML
- End If
-
- Case "loc"
- If window.DialogArguments = "ProfileMgr" Then
- document.all(struser).title = document.all("LockedAccount").innerHTML + " " + document.all("ManageProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("LockedAccount").innerHTML + " " + document.all("ManageProfile").innerHTML
- Else
- document.all(struser).title = document.all("LockedAccount").innerHTML + " " + document.all("RestrictProfile").innerHTML
- document.all("img" & Mid(struser,4)).title = document.all("LockedAccount").innerHTML + " " + document.all("RestrictProfile").innerHTML
- End If
- Case "nop"
- document.all(struser).title = document.all("NoProfile").innerHTML
- Case "gst"
- document.all(struser).title = document.all("Guest").innerHTML
- End Select
-
- ' ~~~ onmouseover high light the user if it is a valid user account
- Select Case Left(strUser,3)
- Case "usr" , "loc" , "dis"
- If Not IsNull(colUsers) Then
- For each oCol in colUsers
- If oCol.classname = "selectuser" Then
- oCol.classname = "unselectuser"
- document.all("img" & Mid(oCol.id,4)).style.visibility = "hidden"
- exit for
- End If
- next
- End If
-
- document.all(strUser).classname = "selectuser"
- document.all("img" & Mid(strUser,4)).style.visibility = "visible"
- ' ~~~ Set the focus on to the column holding the images
- 'document.all("td" & Mid(strUser,4)).ScrollIntoView (False )
- End Select
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: GetHoverText(strUser)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed when the user hovers the
- ' *** mouse over the user account names
- ' *** ------------------------------------------------------------------------------
- ' ***
- Function GetHoverText(strUser)
-
- End Function
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: HTAKeyDown()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is called when any key is pressed while the
- ' *** useraccount dialog is active
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub HTAKeyDown()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- If window.event.keycode = 27 Then
- self.Close()
- ElseIf window.event.keycode = 38 Then
- call moveup()
- ElseIf window.event.keycode = 40 Then
- call movedown()
- ElseIf window.event.keycode = 13 Then
- Call userenter()
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: moveup()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on click of the user name
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub moveup
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Dim ocol, prevUserId,currUserId
- For each ocol in colUsers
- If ocol.classname = "selectuser" Then
- Set currUserId = ocol
- Exit For
- Else
- Set prevUserId = ocol
- End IF
- next
-
- If Not IsEmpty(prevUserId) Then
- ' ~~~ Change the class of the previous and current users
- currUserId.classname="unselectuser"
- document.all("img" & Mid(currUserId.id,4)).style.visibility = "hidden"
- prevUserId.classname="selectuser"
- document.all("img" & Mid(prevUserId.id,4)).style.visibility = "visible"
-
- ' ~~~ Call the mouseover sub to display text
- User_mouseover(prevUserId.id)
-
- ' ~~~ Scroll to the selected user
- 'document.all("td" & Mid(prevUserId.id,4)).ScrollIntoView(True)
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: movedown()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on click of the user name
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub movedown
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Dim bseluser, ocol, SelUserId, newSelUserId
- bseluser = False
- For each ocol in colUsers
- If bseluser = True Then
- Set newSelUserId = ocol
- exit for
- End If
- If ocol.classname = "selectuser" Then
- bseluser = True
- Set SelUserId = ocol
- End If
- next
-
- If Not IsEmpty(newSelUserId) Then
- ' ~~~ Change the class of the previous and current users
- SelUserId.classname = "unselectuser"
- document.all("img" & Mid(SelUserId.id,4)).style.visibility = "hidden"
- newSelUserId.classname = "selectuser"
- document.all("img" & Mid(newSelUserId.id,4)).style.visibility = "visible"
- ' ~~~ Call the mouseover sub to display text
- User_mouseover(newSelUserId.id)
-
- ' ~~~ Scroll to the image next to the selected user
- 'document.all("td" & Mid(newSelUserId.id,4)).ScrollIntoView(False)
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: userenter()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed on click of the user name
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub userenter
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Dim ocol
- ' ~~~ If the collection is not null then proceed
- If Not IsNull(colUsers) Then
- For each ocol in colUsers
- If ocol.classname = "selectuser" Then
- ' ~~~ Call the user_select sub to return the user name
- User_Select(ocol.id)
- Exit For
- End If
- Next
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: HTAUnLoad()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This method unloads all the objects
- ' *** created within the scope of the HTA
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub HTAUnLoad()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Set oUserAccount = Nothing
-
- End Sub