home *** CD-ROM | disk | FTP | other *** search
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Filename: clsWelcome.vbs
- ' *** ------------------------------------------------------------------------------
- ' *** Description: Welcome Class
- ' *** ------------------------------------------------------------------------------
- ' *** Version: 1.0
- ' *** Notes:
- ' *** ------------------------------------------------------------------------------
- ' *** 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
-
-
- Class Welcome
-
- ' ~~~ ------------------------------------------------------------------------------
- ' ~~~ declare variables and constants
- ' ~~~ ------------------------------------------------------------------------------
- Private sUID, bLocal, bDisabled, strRegPath, bLogging
-
- ' ~~~ ------------------------------------------------------------------------------
- ' ~~~ public properties
- ' ~~~ -----------------------------------------------------------------------------
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Property: Logging
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Turns on logging, property must be set to a logging object
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Property Get Logging
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Logging = bLogging
- End Property
-
- Public Property Let Logging(oObject)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- If VarType(oObject) = vbObject Then
- bLogging = True
- Set oLog = oObject
- End If
- End Property
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Property: User
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Username of account modify
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Property Get User
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- User = sUID
- End Property
-
- Public Property Let User(strUser)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- sUID = strUser
- bLocal = IsLocalUser(strUser)
- bDisabled = CheckDisabled(strUser)
- End Property
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Property: IsDisabled
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Is the User already disabled from Windows Welcome
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Property Get IsDisabled
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- IsDisabled = bDisabled
- End Property
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Property: IsLocal
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Is the account a local account?
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Property Get IsLocal
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- IsLocal = bLocal
- End Property
-
- ' ~~~ ------------------------------------------------------------------------------
- ' ~~~ public methods
- ' ~~~ ------------------------------------------------------------------------------
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Enable
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Enables the user account, by removing the account from the
- ' *** UserList Key of the SpecialAccounts in the reigstry.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Function Enable
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- If bLocal Then
- If bDisabled = False Then
- ' ~~~ Account already disabled
- Enable = 2
- Else
- ' ~~~ Add account to Special Accounts list
- Call RegDelete(strRegPath & sUID)
- Enable = 0
- End If
- Else
- ' ~~~ Not a local account
- Enable = 1
- End If
-
- End Function
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Disable
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Disables the user account, by adding the account in the
- ' *** UserList Key of the SpecialAccounts in the reigstry.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Public Function Disable
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- If bLocal Then
- If bDisabled = True Then
- ' ~~~ Account already disabled
- Disable = 2
- Else
- ' ~~~ Disable the account by adding it to the Special Accounts list
- Call RegWrite(strRegPath & sUID, 0, "REG_DWORD")
- Disable = 0
- End If
- Else
- ' ~~~ Not a local account
- Disable = 1
- End If
-
- End Function
-
- ' ~~~ -------------------------------------------------------------------------
- ' ~~~ private methods
- ' ~~~ -------------------------------------------------------------------------
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Class_Initialize
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Used internally by the class when it is created.
- ' *** Declared as private because it must not be called directly.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Private Sub Class_Initialize
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- ' ~~~ set default values for properties
- bLogging = False
-
- strRegPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\SpecialAccounts\UserList\"
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Class_Terminate
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Used internally by the class when it is destroyed.
- ' *** Declared as private because it must not be called directly.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Private Sub Class_Terminate
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: IsLocalUser(strUser)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Returns true if the specified account is a local user
- ' *** ------------------------------------------------------------------------------
- ' ***
- Private Function IsLocalUser(strUser)
- On Error Resume Next
-
- Dim oUser
- Set oUser = GetObject("WinNT://" & sComputer & "/" & strUser & ",user")
-
- If Err.Number <> 0 Then
- ' ~~~ Couldn't find the user, doesn't exist
- IsLocalUser = False
- Else
- ' ~~~ User exists!
- IsLocalUser = True
- End If
-
- End Function
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: CheckDisabled(strUser)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Checks whether the user is already enabled/disabled
- ' *** ------------------------------------------------------------------------------
- ' ***
- Private Function CheckDisabled(strUser)
- On Error Resume Next
-
- Dim strDisabled
-
- strdisabled = RegRead(strRegPath & strUser)
-
- If IsNull(strdisabled) Then
- CheckDisabled = False
- Else
- CheckDisabled = True
- End If
-
- End Function
-
-
- End Class