home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileInclude008 < prev    next >
Encoding:
Text (UTF-16)  |  2005-09-02  |  75.8 KB  |  1,137 lines

  1. ' ***
  2. ' *** ------------------------------------------------------------------------------
  3. ' *** Filename:        clsProfileMgr.vbs
  4. ' *** ------------------------------------------------------------------------------
  5. ' *** Description:    ProfileMgr Class
  6. ' *** ------------------------------------------------------------------------------
  7. ' *** Version:        1.0
  8. ' *** Notes:        
  9. ' *** ------------------------------------------------------------------------------
  10. ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  11. ' *** ------------------------------------------------------------------------------
  12. ' ***
  13.  
  14. ' ~~~ 
  15. ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
  16. ' ~~~ 
  17. Option Explicit
  18.  
  19. Class ProfileMgr
  20.  
  21. ' ~~~ 
  22. ' ~~~ declare variables and constants
  23. ' ~~~ 
  24. Dim bLogging, sUid, sTemplateXML, sUserXML,oLog
  25. Dim sRootKeyE, sRootKeyS
  26. Dim strSelUser, bUserDisabled
  27. Dim sRegLSA,sRegProfileList
  28.  
  29. ' ***
  30. ' *** ------------------------------------------------------------------------------
  31. ' *** Property:    Logging
  32. ' *** ------------------------------------------------------------------------------
  33. ' *** Purpose:    Turns on logging, property must be set to a logging object
  34. ' *** ------------------------------------------------------------------------------
  35. ' ***
  36. Public Property Get Logging
  37.     Logging = bLogging
  38. End Property    
  39.  
  40. Public Property Let Logging(oObject)
  41.     If VarType(oObject) = vbObject Then
  42.         bLogging = True
  43.         Set oLog = oObject
  44.     End If
  45. End Property
  46.  
  47. ' ***
  48. ' *** ------------------------------------------------------------------------------
  49. ' *** Property:    UserSelected
  50. ' *** ------------------------------------------------------------------------------
  51. ' *** Purpose:    Stores the user selected from useraccounts.hta
  52. ' *** ------------------------------------------------------------------------------
  53. ' ***
  54. Public Property Get UserSelected
  55.     UserSelected = strSelUser
  56. End Property    
  57.  
  58. Public Property Let UserSelected(sSelUser)
  59.     strSelUser = sSelUser
  60. End Property
  61.  
  62. ' ***
  63. ' *** ------------------------------------------------------------------------------
  64. ' *** Property:    IsUserDisabled
  65. ' *** ------------------------------------------------------------------------------
  66. ' *** Purpose:    Stores whether the user is disabled or not
  67. ' *** ------------------------------------------------------------------------------
  68. ' ***
  69. Public Property Get IsUserDisabled
  70.     IsUserDisabled = bUserDisabled
  71. End Property  
  72.  
  73. Public Property Let IsUserDisabled(busrDisabled)
  74.     bUserDisabled = busrDisabled
  75. End Property  
  76.  
  77. ' ~~~ 
  78. ' ~~~ Start of public methods
  79. ' ~~~ 
  80.  
  81. ' ***
  82. ' *** ------------------------------------------------------------------------------
  83. ' *** Name:        CreateProfiles(sUserName, sPassword, sDomain, sDrive)
  84. ' *** ------------------------------------------------------------------------------
  85. ' *** Purpose:    Creates the profile for the user name and password in the specified drive 
  86. ' *** ------------------------------------------------------------------------------
  87. ' ***
  88. Public Function CreateProfiles(sUserName, sPassword, sDomain, sDrive)
  89.     
  90.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  91.     
  92.     Dim limitblankpasswd, defProfilePath, sdefaultPath 
  93.     Dim sRootDir,sNewProfile,sUserID
  94.     
  95.     If IsLocalUser(sUserName) Then
  96.         If bLogging Then oLog.Write("clsProfileMgr  - CreateProfiles(): The account " & sUserName & " is a local account")
  97.         ' ~~~ Check if the local user is disabled
  98.         If IsAccDisabled(sUserName) Then 
  99.             bUserDisabled = True
  100.             If bLogging Then oLog.Write("clsProfileMgr  - CreateProfiles(): The account " & sUserName & " is currently disabled")
  101.             Call AccountDisable(sUserName, False)
  102.         End If
  103.         sUserID = GetUserSID(sUserName)
  104.     Else
  105.         If bLogging Then oLog.Write("clsProfileMgr  - CreateProfiles(): The account " & sUserName & " is a domain account")
  106.         sUserID = GetSID(sUserName)
  107.     End If
  108.             
  109.     ' ~~~ Store the limitblankpassworduse registry value 
  110.     limitblankpasswd = RegRead(sRegLSA)
  111.     ' ~~~ Set the limitblankpassworduse registry value to 0 to support for blank passwords
  112.     RegWrite sRegLSA,0, "REG_DWORD"  
  113.         
  114.     ' ~~~ Get the Default profiles directory and store it in a variable
  115.     ' ~~~ Use WMI registry call
  116.     defProfilePath = RegRead(sRegProfileList & "\ProfilesDirectory")
  117.     
  118.     ' ~~~ copy the default to another string
  119.     sdefaultPath = defProfilePath 
  120.     
  121.     ' ~~~ Get the systemroot directory
  122.     sRootDir = Left(oShell.ExpandEnvironmentStrings (sdefaultPath) , 2)
  123.     
  124.     ' ~~~ Set domain to (.) if null
  125.     If sDomain = "" Then sDomain = "."
  126.         
  127.     ' ~~~ Call the private function to create the profile
  128.     CreateProfiles = MakeProfile(sUserName,sPassword,sDomain)
  129.         
  130.     If CreateProfiles = 0 Then
  131.         If (sDrive <> "") AND (UCase(sDrive) <> UCase(sRootDir) ) Then
  132.             
  133.             ' ~~~ Copy the profile to the new location
  134.             sNewProfile = MoveProfile(sdefaultPath , sDrive, sUserName )
  135.             ' ~~~ Change the profileimagepath of the user to the new location
  136.             RegWrite sRegProfileList & "\"& sUserID &"\ProfileImagePath" , sNewProfile, "REG_EXPAND_SZ"        
  137.         End If        
  138.     End If    
  139.     
  140.     ' ~~~ Disable the user account if already disabled
  141.     If bUserDisabled Then
  142.         Call AccountDisable(sUserName, True)    
  143.     End If
  144.  
  145.     ' ~~~ Reset the limitblankpassworduse registry value to 1
  146.     RegWrite sRegLSA,limitblankpasswd, "REG_DWORD"  
  147.  
  148. End Function
  149.  
  150. ' ***
  151. ' *** ------------------------------------------------------------------------------
  152. ' *** Name:        CreateUserAccounts()
  153. ' *** ------------------------------------------------------------------------------
  154. ' *** Purpose:    Manage(create/delete/modify) user accounts.
  155. ' *** ------------------------------------------------------------------------------
  156. ' ***
  157. Public Function CreateUserAccounts()
  158.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  159.     
  160.     Dim systemDir 
  161.  
  162.     ' ~~~ Get the system root directory
  163.     systemDir = Getsystemroot
  164.  
  165.     if bDomainMember Then
  166.         ' ~~~ Run the Control Panel Applet using the control.exe
  167.         oShell.run systemDir & "\lusrmgr.msc",1,true
  168.     Else
  169.         ' ~~~ Run the Control Panel Applet using the control.exe
  170.         oShell.run "control.exe " & systemDir & "\nusrmgr.cpl",1,true
  171.     End If
  172.     
  173. End Function
  174.  
  175. ' ***
  176. ' *** ------------------------------------------------------------------------------
  177. ' *** Name:        DeleteProfiles(sUser, sdomainname)
  178. ' *** ------------------------------------------------------------------------------
  179. ' *** Purpose:    Deletes the profile of the selected user.
  180. ' *** ------------------------------------------------------------------------------
  181. ' ***
  182. Public Function DeleteProfiles(sUser, sdomainname)
  183.     
  184.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  185.     
  186.     Dim oUser, strProfilepath, strProfileImgpath
  187.     
  188.     ' ~~~ Turn on error handling ...
  189.     On Error Resume Next ' RegRead will fail if there is no regkey
  190.     If sUser = "" Then
  191.         DeleteProfiles = 1
  192.         Exit Function
  193.     End If
  194.     
  195.     ' ~~~ Check the domainname, if null then change to local(.)
  196.         
  197.     ' ~~~ If username account exists in the machine
  198.     If IsLocalUser(sUser) = True Then
  199.         If bLogging Then oLog.Write("clsProfileMgr  - DeleteProfiles(): The account " & sUser & " is a local account")
  200.         ' ~~~ Check if the user account is disabled
  201.         If IsAccDisabled(sUser) Then 
  202.             bUserDisabled = True
  203.             ' ~~~ Enable the user account that is disabled
  204.             Call AccountDisable(sUser, False)    
  205.         End If
  206.         
  207.         ' ~~~ get the profile path 
  208.         Set oUser = GetObject("WinNT://" & sComputer & "/" & sUser)   
  209.         strProfilepath = oUser.Profile
  210.         strProfilepath = oShell.ExpandEnvironmentStrings( strProfilepath )
  211.         
  212.         ' ~~~ Use WMI registry call
  213.         strProfileImgpath = RegRead( sRegProfileList & "\"& GetUserSID(sUser) &"\ProfileImagePath")  
  214.         ' ~~~ if registry hive exists for the user
  215.         
  216.         strProfileImgpath = oShell.ExpandEnvironmentStrings( strProfileImgpath )
  217.  
  218.         ' ~~~ Call the DelProfile private function
  219.         DeleteProfiles = DelProfile(sUser, strProfileImgpath, strProfilepath)
  220.         
  221.         If DeleteProfiles = 0 Then
  222.             ' ~~~ Reset the profilepath of the user to null 
  223.             oUser.Profile = ""
  224.             oUser.SetInfo
  225.         End If
  226.  
  227.         ' ~~~ Disable the user account if it was previously disabled
  228.         If bUserDisabled Then
  229.             Call AccountDisable(sUser, True)    
  230.         End If
  231.     Else
  232.         If bLogging Then oLog.Write("clsProfileMgr  - DeleteProfiles(): The account " & sUser & " is a domain account")
  233.         ' ~~~ The user account is not in the machine
  234.         DeleteProfiles = DelDomainProfile(sUser,sdomainname)
  235.     End If
  236.              
  237.     Set oUser = Nothing
  238.  
  239. End Function
  240.  
  241. ' ***
  242. ' *** ------------------------------------------------------------------------------
  243. ' *** Name:        GetProfilePath(sUser)
  244. ' *** ------------------------------------------------------------------------------
  245. ' *** Purpose:    Gets the profile path for the seleted user
  246. ' *** ------------------------------------------------------------------------------
  247. ' ***
  248. Public Function GetProfilePath(sUser)
  249.     
  250.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  251.     
  252.     Dim oAccount, sProfilePath
  253.     
  254.     ' ~~~ turn on error handling
  255.     On Error Resume Next
  256.  
  257.     ' ~~~ first look for locked profiles
  258.     sProfilePath = ""
  259.     Set oAccount = GetObject("WinNT://" & sComputer & "/" & sUser)
  260.     sProfilePath = oAccount.Profile
  261.  
  262.     ' ~~~ if profile path is still blank, it is not locked so get profile path using sid 
  263.     If sProfilePath = "" Then 
  264.         sProfilePath = RegRead(sRegProfileList & "\"& GetUserSID(sUser) &"\ProfileImagePath")
  265.     End If
  266.  
  267.     ' ~~~ return path
  268.     GetProfilePath = oShell.ExpandEnvironmentStrings(sProfilePath)
  269.     
  270. End Function
  271.  
  272. ' ***
  273. ' *** ------------------------------------------------------------------------------
  274. ' *** Name:            GetUserSID(sUID)
  275. ' *** ------------------------------------------------------------------------------
  276. ' *** Purpose:        Returns the users SID
  277. ' *** ------------------------------------------------------------------------------
  278. ' ***
  279. Public Function GetUserSID(sUID)
  280.     
  281.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  282.     
  283.     Dim oAccount
  284.     
  285.     ' ~~~ turn on error handling
  286.     On Error Resume Next
  287.     
  288.     ' ~~~ create wmi object & get sid
  289.     Set oAccount    = oWMIService.Get("Win32_UserAccount.Name='" & sUID & "',Domain='" & oNetwork.ComputerName & "'")
  290.  
  291.     ' ~~~ return the sid
  292.     GetUserSID = oAccount.SID
  293.     
  294.     Set oAccount = Nothing
  295. End Function
  296.  
  297. ' ***
  298. ' *** ------------------------------------------------------------------------------
  299. ' *** Name:        ShowUserAndProfile()
  300. ' *** ------------------------------------------------------------------------------
  301. ' *** Purpose:    Shows the user and profile path in commandline
  302. ' *** ------------------------------------------------------------------------------
  303. ' ***
  304. Public Function ShowUserAndProfile
  305.     
  306.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  307.     
  308.     Dim oAccounts, oUser, sHTML,sUserPath,strProfilePath
  309.  
  310.     ' ~~~ get a list of user accounts on the local machine
  311.     Set oAccounts = GetObject("WinNT://" & sComputer)
  312.     oAccounts.Filter = Array("user")
  313.     For Each oUser in oAccounts 
  314.         If IsInValidAccount(oUser) = False Then
  315.             strProfilePath = GetProfilePath(oUser.Name)
  316.             If strProfilePath  <> "" Then
  317.                 wscript.Echo oUser.Name&" : " & strProfilePath
  318.             Else
  319.                 Wscript.Echo oUser.Name & " : " 
  320.             End If
  321.  
  322.         End If 
  323.     Next
  324.     
  325.     Set oUser = Nothing
  326.     Set oAccounts = Nothing
  327.  
  328. End Function
  329.  
  330. ' ***
  331. ' *** ------------------------------------------------------------------------------
  332. ' *** Name:        CheckArguments(sArgs)
  333. ' *** ------------------------------------------------------------------------------
  334. ' *** Purpose:    Check the arguments that are passed to the /create option
  335. ' ***        in the command line and returns the arguments.
  336. ' ***        This function is called when only /create is entered in commandline
  337. ' *** ------------------------------------------------------------------------------
  338. ' ***
  339. Public Function CheckArguments(sArgs)
  340.  
  341.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  342.  
  343.     Dim struser, strpassword, strdomain, strdrive
  344.  
  345.     struser = Trim(sArgs(0))
  346.     strpassword = Trim(sArgs(1))
  347.     strdomain = Trim(sArgs(2))
  348.     strdrive = Trim(sArgs(3))
  349.  
  350.     If strdomain = "" Then
  351.         strdomain = "."
  352.     End If
  353.  
  354.     ' ~~~ Call the IsValidInputs function to validate the inputs
  355.     CheckArguments = IsValidInputs( struser, strpassword, strdomain, strdrive )
  356.  
  357.     If UBound(CheckArguments) <> 0 Then
  358.         ' ~~~ Return the username,password,domain and drive as an array
  359.         CheckArguments = Array(struser,strpassword,strdomain,strdrive)
  360.     End If
  361.  
  362. End Function
  363.  
  364. ' ***
  365. ' *** ------------------------------------------------------------------------------
  366. ' *** Name:        CreateArgs(sCreateArgs)
  367. ' *** ------------------------------------------------------------------------------
  368. ' *** Purpose:    Check the arguments that are passed to the /create option
  369. ' ***        in the command line and returns the arguments.
  370. ' ***        This function is called if arguements are also passed with the
  371. ' ***        /create option
  372. ' *** ------------------------------------------------------------------------------
  373. ' ***
  374. Public Function CreateArgs(sCreateArgs)
  375.  
  376.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  377.  
  378.     Dim struser, strpassword, strdomain, strdrive
  379.  
  380.     ' ~~~ Assign the username
  381.     struser     = sCreateArgs(0)
  382.     strpassword = sCreateArgs(1)
  383.     strdomain   = sCreateArgs(2)
  384.     strdrive    = sCreateArgs(3)
  385.         
  386.     ' ~~~ Set the domain to local (.) if null
  387.     If strdomain = "" Then strdomain = "."
  388.  
  389.     ' ~~~ Call the IsValidInputs function to validate the inputs
  390.     CreateArgs = IsValidInputs( struser, strpassword, strdomain, strdrive )
  391.  
  392.     If UBound(CreateArgs) <> 0 Then
  393.         ' ~~~ Return the username,password,domain and drive as an array
  394.         CreateArgs = Array(struser,strpassword,strdomain,strdrive)
  395.     End If
  396.  
  397. End Function
  398.  
  399. ' ***
  400. ' *** ------------------------------------------------------------------------------
  401. ' *** Name:        DelArguments(sDelArgs)
  402. ' *** ------------------------------------------------------------------------------
  403. ' *** Purpose:    Check the arguments that are passed to the /delete option
  404. ' ***        in the command line and returns the arguments.
  405. ' *** ------------------------------------------------------------------------------
  406. ' ***
  407. Public Function DelArguments(sDelArgs)
  408.  
  409.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  410.  
  411.     Dim sUserArg, sDomainArg, OUser
  412.  
  413.     sUserArg = Trim(sDelArgs(0))
  414.     sDomainArg = Trim(sDelArgs(1))
  415.     
  416.     ' ~~~ Validations for the user and domain
  417.  
  418.     ' ~~~ Change the domain to (.) for local machine
  419.     If sDomainArg = "" or UCase(sDomainArg) = UCase(oNetwork.ComputerName) Then sDomainArg = "."
  420.     
  421.     ' ~~~ If user name is not provided
  422.     If sUserArg = "" Then
  423.         DelArguments = Array("1")
  424.         Exit Function
  425.     Else
  426.         ' ~~~ Check whether the user is logged on
  427.         If oNetwork.UserDomain = oNetwork.ComputerName Then
  428.             ' ~~~ check for the logged on local user 
  429.             If ( UCase(sUserArg) = UCase(oNetwork.UserName)) Then
  430.                 ' ~~~ return 2 to show the error message 
  431.                 DelArguments = Array("2")
  432.                 Exit Function
  433.             End If
  434.  
  435.             ' ~~~ Check for user logged on through fast-user-switching
  436.             Set OUser = GetObject("WinNT://" & sComputer & "/" & sUserArg )
  437.             If IsUserLoggedOn(OUser) Then
  438.  
  439.                 ' ~~~ return 3 to show the error message 
  440.                 DelArguments = Array("3")
  441.                 Exit Function
  442.             End If
  443.         Else
  444.             ' ~~~ check for the logged on domain user 
  445.             If UCase(sUserArg) = UCase(oNetwork.UserName) Then
  446.                 DelArguments = Array("2")
  447.                 Exit Function
  448.             End If
  449.         End If
  450.         
  451.         ' ~~~ Check for the valid user and valid domain specified for that user        
  452.         If IsLocalUser(sUserArg) = True Then
  453.             ' ~~~ Check if the domain is valid for the local user
  454.             If sDomainArg <> "" and sDomainArg <> oNetwork.ComputerName and sDomainArg <> "." Then
  455.                 DelArguments = Array("6")
  456.                 Exit Function
  457.             End If
  458.             ' ~~~ Check if profile exists for the local user
  459.             If (IsProfileExists(sUserArg) = 0) Then
  460.                 ' ~~~ Set the return value as 7 to indicate the error
  461.                 DelArguments = Array("7")
  462.                 Exit Function
  463.             End If
  464.         ElseIf (sDomainArg <> "" and sDomainArg <> oNetwork.ComputerName and sDomainArg <> "." and IsLocalUser(sUserArg) = False) Then
  465.                 ' ~~~ Check if profile exists for the domain user
  466.                 If (GetSID(sUserArg) = "") Then
  467.                     ' ~~~ Set the return value as 7 to indicate the error
  468.                     DelArguments = Array("7")
  469.                     Exit Function
  470.                 End If
  471.  
  472.         Else
  473.             DelArguments = Array("5")
  474.             Exit Function
  475.  
  476.         End If
  477.     End If
  478.  
  479.     ' ~~~ return the username and domain
  480.     DelArguments = Array(sUserArg, sDomainArg)
  481.     
  482. End Function
  483.  
  484. ' ***
  485. ' *** ------------------------------------------------------------------------------
  486. ' *** Name:            AccountDisable(strdisUser, bDisable)
  487. ' *** ------------------------------------------------------------------------------
  488. ' *** Purpose:        This subroutine is executed to enable/disalbe user account
  489. ' *** ------------------------------------------------------------------------------
  490. ' ***
  491. Public Function AccountDisable(strdisUser,bDisable)
  492.     
  493.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  494.     
  495.     Dim usr
  496.     
  497.     Set usr = GetObject("WinNT://" & sComputer & "/" & strdisUser )
  498.     
  499.     If bDisable Then
  500.         usr.AccountDisabled = True
  501.         usr.SetInfo
  502.     Else
  503.         usr.AccountDisabled = False
  504.         usr.SetInfo
  505.     End If
  506.     
  507.     Set usr = Nothing
  508. End Function
  509.  
  510. ' ***
  511. ' *** ------------------------------------------------------------------------------
  512. ' *** Name:            IsAccDisabled(sdisableUser)
  513. ' *** ------------------------------------------------------------------------------
  514. ' *** Purpose:        To check whether the user account is disabled or not.
  515. ' *** ------------------------------------------------------------------------------
  516. ' ***
  517. Public Function IsAccDisabled(sdisableUser)
  518.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  519.     
  520.     Dim usr
  521.     
  522.     IsAccDisabled = False
  523.     
  524.     Set usr = GetObject("WinNT://" & sComputer & "/" & sdisableUser )
  525.     
  526.     If usr.AccountDisabled <> 0 Then IsAccDisabled = True
  527.     
  528.     Set usr = Nothing
  529. End Function
  530.  
  531. ' ~~~ -------------------------------------------------------------------------
  532. ' ~~~ End of public methods
  533. ' ~~~ -------------------------------------------------------------------------
  534.  
  535. ' ~~~ -------------------------------------------------------------------------
  536. ' ~~~ Start of private methods
  537. ' ~~~ -------------------------------------------------------------------------
  538.  
  539. ' ***
  540. ' *** ------------------------------------------------------------------------------
  541. ' *** Name:        Class_Initialize
  542. ' *** ------------------------------------------------------------------------------
  543. ' *** Purpose:    Used internally by the class when it is created.
  544. ' ***        Declared as private because it must not be called directly.
  545. ' *** ------------------------------------------------------------------------------
  546. ' ***
  547. Private Sub Class_Initialize
  548.     
  549.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  550.     bLogging = True
  551.     
  552.     sRootKeyE  = "HKU\SSW"                ' EXE
  553.     sRootKeyS  = "HKEY_USERS\SSW"        ' SCRIPT
  554.     sRegLSA       = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\limitblankpassworduse"
  555.     sRegProfileList = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
  556.  
  557. End Sub
  558.  
  559. ' ***
  560. ' *** ------------------------------------------------------------------------------
  561. ' *** Name:        Class_Terminate
  562. ' *** ------------------------------------------------------------------------------
  563. ' *** Purpose:    Used internally by the class when it is destroyed.
  564. ' ***            Declared as private because it must not be called directly.
  565. ' *** ------------------------------------------------------------------------------
  566. ' ***
  567. Private Sub Class_Terminate
  568.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  569. End Sub
  570.  
  571. ' ***
  572. ' *** ------------------------------------------------------------------------------
  573. ' *** Name:        Getsystemroot()
  574. ' *** ------------------------------------------------------------------------------
  575. ' *** Purpose:    Returns the system root directory
  576. ' ***        Used for running the control.exe 
  577. ' *** ------------------------------------------------------------------------------
  578. ' ***
  579. Private Function Getsystemroot()
  580.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  581.     Dim systemDir 
  582.  
  583.     systemDir = oShell.ExpandEnvironmentStrings("%SYSTEMROOT%")
  584.     systemDir = systemDir & "\system32"
  585.  
  586.     ' ~~~ Return the root directory
  587.     Getsystemroot = systemDir 
  588.  
  589. End Function
  590.  
  591. ' ***
  592. ' *** ------------------------------------------------------------------------------
  593. ' *** Name:        MoveProfile(sSystemDir, sDesdrive, sCurrentUser)
  594. ' *** ------------------------------------------------------------------------------
  595. ' *** Purpose:    The profile created in default drive is moved to selected drive.
  596. ' *** ------------------------------------------------------------------------------
  597. ' ***
  598. Private Function MoveProfile(sSystemDir , sDesdrive, sCurrentUser)
  599.     
  600.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  601.     
  602.     Dim sCurrentLoc, sDesLocation, oFolder , iCharPosStart , iCharPosEnd, strPROFILEFOLDER 
  603.     
  604.     Const OVERWRITEFILES = True
  605.     
  606.     ' ~~~ Expand the environment variables in the default profiles directory
  607.     sSystemDir = oShell.ExpandEnvironmentStrings (sSystemDir) 
  608.     
  609.     strPROFILEFOLDER = sDesdrive & Mid( sSystemDir , 3 )
  610.     
  611.     ' ~~~ Get the last occurence of "\"
  612.     iCharPosEnd = InstrRev( strPROFILEFOLDER  , "\" )
  613.     
  614.     ' ~~~ Get the first occurence of "\"
  615.     iCharPosStart = Instr( strPROFILEFOLDER , "\" )
  616.         
  617.     ' ~~~ Check whether all the parent folders exists, if not create them
  618.     While iCharPosStart < iCharPosEnd 
  619.         ' ~~~ Get the occurence of "\"
  620.         iCharPosStart = Instr( iCharPosStart , strPROFILEFOLDER , "\" )
  621.         
  622.         If NOT oFso.FolderExists( Left( strPROFILEFOLDER ,  iCharPosStart - 1)) Then
  623.             ' ~~~ Create the folder
  624.             oFolder = oFso.CreateFolder( Left( strPROFILEFOLDER ,  iCharPosStart - 1) )
  625.         End If
  626.         
  627.         iCharPosStart = iCharPosStart + 1
  628.     Wend
  629.     
  630.     ' ~~~ Check for the existence of last folder in the destination path
  631.     If NOT oFso.FolderExists( strPROFILEFOLDER ) Then
  632.         ' ~~~ Create the folder
  633.         oFolder = oFso.CreateFolder( strPROFILEFOLDER )
  634.     End If
  635.     
  636.     ' ~~~ Append the username to the profile path
  637.     sCurrentLoc  = sSystemDir & "\" & sCurrentUser
  638.     sDesLocation = strPROFILEFOLDER & "\" & sCurrentUser
  639.         
  640.     ' ~~~ Copy the profile folder
  641.     If oFso.FolderExists(sCurrentLoc) Then
  642.         ' ~~~ Copy the profile folder from the default location to the selected drive
  643.         oFso.CopyFolder sCurrentLoc, sDesLocation, OVERWRITEFILES
  644.         ' ~~~ Delete the old profile folder
  645.         oFso.DeleteFolder sCurrentLoc , True
  646.     End If
  647.     If bLogging Then oLog.Write("clsProfileMgr  - MoveProfile(): The Profile for " & sCurrentUser & " is created in " & sDesdrive)
  648.     
  649.     ' ~~~ Return the new profile location
  650.     MoveProfile = sDesLocation
  651.     
  652. End Function
  653.  
  654. ' ***
  655. ' *** ------------------------------------------------------------------------------
  656. ' *** Name:        DelProfile(strUser, sprofileImgpath, sprofilepath)
  657. ' *** ------------------------------------------------------------------------------
  658. ' *** Purpose:    Deletes the profile folder,orig folder if locked and registry 
  659. ' *** ------------------------------------------------------------------------------
  660. ' ***
  661. Private Function DelProfile(strUser, sprofileImgpath, sprofilepath)
  662.  
  663.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  664.  
  665.     Dim strUserSID, oUser 
  666.     DelProfile = 0
  667.     ' ~~~ Turn on error handling
  668.     On Error Resume Next
  669.  
  670.     strUserSID = GetUserSID(strUser)
  671.     err.clear
  672.     If sprofileImgpath <> "" Then
  673.         If oFso.FolderExists ( sprofileImgpath ) = True Then
  674.             oFso.DeleteFolder sprofileImgpath , True
  675.             If err.number = 0 Then
  676.                 DelProfile = 0
  677.             Else
  678.                 DelProfile = 1
  679.                 Exit Function
  680.             End If
  681.         End If    
  682.     End If
  683.     err.clear
  684.     If sprofilepath <> "" Then
  685.         If oFso.FolderExists ( sprofilepath ) = True Then
  686.             oFso.DeleteFolder sprofilepath , True
  687.             If err.number = 0 Then
  688.                 DelProfile = 0
  689.             Else
  690.                 DelProfile = 1
  691.                 Exit Function
  692.             End If
  693.         End If
  694.     End If
  695.     oShell.RegDelete sRegProfileList & "\" & strUserSID & "\"  
  696.     
  697. End Function
  698.  
  699. ' ***
  700. ' *** ------------------------------------------------------------------------------
  701. ' *** Name:        MakeProfile(StrUser, StrPassword, StrDomain)
  702. ' *** ------------------------------------------------------------------------------
  703. ' *** Purpose:    creates profile for the selected the user by using createprofile.exe
  704. ' ***        Returns true on success else returns false    
  705. ' *** ------------------------------------------------------------------------------
  706. ' ***
  707. Private Function MakeProfile(StrUser, StrPassword, StrDomain)
  708.     
  709.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  710.     
  711.     Dim UserSID, bProfile, sCommand
  712.     
  713.     ' ~~~ Turn on error handling
  714.     On Error Resume Next
  715.     
  716.     if StrUser = "" Then
  717.         MakeProfile = 1
  718.         exit function
  719.     End If
  720.     
  721.     If StrDomain = " " or UCase(StrDomain) = UCase(oNetwork.ComputerName) Then
  722.         StrDomain = "."
  723.     End If
  724.     
  725.     sCommand = Chr(34) & GetRootFolder & "\bin" & "\CreateProfile.exe" & Chr(34)_
  726.         & StrDomain & "," & StrUser & "," & StrPassword 
  727.     bProfile = oShell.Run (sCommand, 7, True)
  728.  
  729.     If bProfile = 1 Then
  730.         ' ~~~ Profile created successfully
  731.         MakeProfile = 0 
  732.     Else
  733.         MakeProfile = 1
  734.     End If
  735.         
  736.     Set oAccount = Nothing
  737. End Function
  738.  
  739. ' ***
  740. ' *** ------------------------------------------------------------------------------
  741. ' *** Name:            IsUserLoggedOn(oUser)
  742. ' *** ------------------------------------------------------------------------------
  743. ' *** Purpose:        Returns true if the specified account is logged on
  744. ' *** ------------------------------------------------------------------------------
  745. ' ***
  746. Private Function  IsUserLoggedOn(oUser)
  747.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  748.  
  749.     Dim sNTUser, oFile, oFileStream
  750.     
  751.     Const FORAPPENDING  = 8
  752.     Const TRISTATEUSEDEFAULT = -2
  753.  
  754.     IsUserLoggedOn = False
  755.  
  756.     If IsAccountLocked(oUser) = True Then
  757.         sNTUser = "\NTUSER.MAN"
  758.     Else
  759.         sNTUser = "\NTUSER.DAT"
  760.     End If 
  761.  
  762.     ' ~~~ We need to control error handling for the rest of this function
  763.     On Error Resume Next
  764.  
  765.     Set oFile = oFso.GetFile(GetProfilePath(oUser.Name) & sNTUser)
  766.     ' ~~~ If we can't find the NTUSER file then it doesn't exist - so the user cannot be logged on
  767.     If Err.Number <> 0 Then    Exit Function 
  768.  
  769.     Set oFileStream = oFile.OpenAsTextStream(FORAPPENDING, TRISTATEUSEDEFAULT)
  770.     ' ~~~ If we can't open the NTUSER file exclusively, then someone must already be using it
  771.     If Err.Number <> 0 Then    IsUserLoggedOn = True 
  772. End Function
  773.  
  774. ' ***
  775. ' *** ------------------------------------------------------------------------------
  776. ' *** Name:            IsLocalUser(sLocUser)
  777. ' *** ------------------------------------------------------------------------------
  778. ' *** Purpose:        Returns true if the specified account is a local user
  779. ' *** ------------------------------------------------------------------------------
  780. ' ***
  781. Private Function IsLocalUser(sLocUser)
  782.     
  783.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  784.     
  785.     Dim colAccounts, oUser    
  786.         
  787.     Set colAccounts = GetObject("WinNT://" & sComputer & "")
  788.     colAccounts.Filter = Array("user")
  789.     For Each oUser In colAccounts
  790.         If UCase(sLocUser) = UCase(oUser.Name) Then
  791.             IsLocalUser = True
  792.             Exit For
  793.         Else
  794.             IsLocalUser = False
  795.         End If
  796.     Next
  797.  
  798. End Function
  799.  
  800. ' ***
  801. ' *** ------------------------------------------------------------------------------
  802. ' *** Name:            DelDomainProfile(sDomUser,sDomName)
  803. ' *** ------------------------------------------------------------------------------
  804. ' *** Purpose:        This function is used to delete the domain user pofiles
  805. ' *** ------------------------------------------------------------------------------
  806. ' ***
  807. Private Function DelDomainProfile(sDomUser,sDomName)
  808.     
  809.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  810.     
  811.     Dim bRegResult, bRegDelete, strComputer, oReg, sDomUserSID, strKeyPath
  812.     Dim strValueName, strValue
  813.     
  814.     ' ~~~ Turn on error handling
  815.     On Error Resume Next
  816.     
  817.     const HKEY_LOCAL_MACHINE = &H80000002
  818.     strComputer = "."
  819.     
  820.     Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
  821.      strComputer & "\root\default:StdRegProv")
  822.     
  823.     sDomUserSID = GetSID(sDomUser) 
  824.     
  825.     strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & sDomUserSID
  826.     strValueName = "ProfileImagePath"
  827.     
  828.     bRegResult = oReg.GetStringValue (HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
  829.     
  830.     If bRegResult = 0 Then
  831.         If oFso.FolderExists (strValue) = True Then
  832.             oFso.DeleteFolder strValue , True 
  833.         End If
  834.         err.clear
  835.         oShell.RegDelete sRegProfileList & "\" & sDomUserSID  & "\" 
  836.     End If    
  837.      
  838.     If err.number = 0 Then
  839.         DelDomainProfile = 0
  840.     Else
  841.         DelDomainProfile = 1
  842.     End If
  843.     
  844.     ' ~~~ Turn off error handling 
  845.     on error goto 0
  846.     Set oReg = Nothing
  847. End Function
  848.  
  849. ' ***
  850. ' *** ------------------------------------------------------------------------------
  851. ' *** Name:            GetSID(sdomUser)
  852. ' *** ------------------------------------------------------------------------------
  853. ' *** Purpose:        Get the SID for the user whose account is not in the 
  854. ' ***            machine
  855. ' *** ------------------------------------------------------------------------------
  856. ' ***
  857. Private Function GetSID(sdomUser)
  858.     
  859.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  860.     
  861.     ' ~~~ Turn on error handling
  862.     On Error Resume Next
  863.     
  864.     Dim strComputer, oReg, strKeyPath, strProfImgPath, strValueName 
  865.     Dim arrSubKeys, subkey, strValue
  866.     
  867.     ' ~~~ To Get the SID from registry
  868.     const HKEY_LOCAL_MACHINE = &H80000002
  869.     strComputer = "."
  870.      
  871.     Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
  872.     strComputer & "\root\default:StdRegProv")
  873.      
  874.     strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
  875.     oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
  876.     
  877.     strProfImgPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
  878.     strValueName = "ProfileImagePath"
  879.     
  880.     ' ~~~ Loop through all the SID's in the registry
  881.     For Each subkey In arrSubKeys
  882.         oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, strValueName, strValue
  883.         
  884.         strValue = Mid(strValue, InStrRev(strValue, "\") +1)
  885.         
  886.         If (UCase(strValue) = UCase(sdomUser)) Then
  887.             ' ~~~ return the SID
  888.             GetSID = subkey
  889.         End If
  890.     Next    
  891. End Function
  892.  
  893. ' ***
  894. ' *** ------------------------------------------------------------------------------
  895. ' *** Name:            IsValidDrive(sdriveID)
  896. ' *** ------------------------------------------------------------------------------
  897. ' *** Purpose:        Checks whether the drive entered in the /create option
  898. ' ***            is a valid drive
  899. ' *** ------------------------------------------------------------------------------
  900. ' ***
  901. Private Function IsValidDrive(sdriveID)
  902.     
  903.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  904.     
  905.     Dim colDiskDrives, oDisks 
  906.     
  907.     ' ~~~ To check whether the drive is a hard disk
  908.     const HARD_DISK = 3 
  909.         
  910.     If Right(sdriveID,1) <> ":" Then
  911.         sdriveID = sdriveID & ":"
  912.     End If
  913.     Set colDiskDrives = oWMIService.ExecQuery _    
  914.         ("Select * from Win32_LogicalDisk where DriveType =" & HARD_DISK & "" )
  915.     
  916.     For Each oDisks in colDiskDrives 
  917.         If oDisks.FileSystem <> "" Then
  918.             If UCase(oDisks.DeviceID) = UCase(sdriveID) Then
  919.                 IsValidDrive = True
  920.             End If
  921.         End If
  922.     Next
  923.                 
  924. End Function
  925.  
  926. ' ***
  927. ' *** ------------------------------------------------------------------------------
  928. ' *** Name:            IsProfileExists(sLocalUser)
  929. ' *** ------------------------------------------------------------------------------
  930. ' *** Purpose:        Checks whether profile exists for the local user before 
  931. ' ***            deleting. 
  932. ' *** ------------------------------------------------------------------------------
  933. ' ***
  934. Private Function IsProfileExists(sLocalUser)
  935.     
  936.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  937.     
  938.     Dim strProfilePath1, strProfilePath2, oUser
  939.  
  940.     strProfilePath1 = ""
  941.     strProfilePath2 = ""
  942.  
  943.     ' ~~~ Need to ignore errors for a moment
  944.     On Error Resume Next
  945.  
  946.     ' ~~~ get the profile path attribute from the account
  947.     Set oUser = GetObject("WinNT://" & sComputer & "/" & sLocalUser)   
  948.     strProfilePath1 = oUser.Profile
  949.  
  950.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  951.  
  952.     ' ~~~ Get the profile path attribute from the registry (if it exists)
  953.     strProfilePath2 = RegRead( sRegProfileList & "\" & GetUserSID(sLocalUser) & "\ProfileImagePath" )
  954.  
  955.     If (strProfilePath1 <> "") or (strProfilePath2 <> "") Then
  956.         IsProfileExists = 1
  957.     Else
  958.         IsProfileExists = 0
  959.     End If
  960.  
  961. End Function
  962.  
  963. ' ***
  964. ' *** ------------------------------------------------------------------------------
  965. ' *** Name:            IsValidInputs(strUSER, strPASS, strDOMAIN, strDRIVE)
  966. ' *** ------------------------------------------------------------------------------
  967. ' *** Purpose:        Validates the inputs that are entered with the  
  968. ' ***            /create option
  969. ' *** ------------------------------------------------------------------------------
  970. Private Function IsValidInputs(strUSER, strPASS, strDOMAIN, strDRIVE)
  971.     
  972.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  973.     
  974.     ' ~~~ Check for the validity of the user
  975.     If strUSER = "" Then
  976.         IsValidInputs = Array("1")
  977.         Exit Function
  978.     Else
  979.         ' ~~~ Check the domain specified for the local user
  980.         If IsLocalUser(strUSER) = True Then
  981.             If strDOMAIN <> "" and strDOMAIN <> oNetwork.ComputerName and strDOMAIN <> "." Then
  982.                 IsValidInputs = Array("6")
  983.                 Exit Function
  984.             End If
  985.             If IsProfileExists(strUSER) = 1 Then
  986.                 IsValidInputs = Array("7")
  987.                 Exit Function
  988.             End If
  989.         ' ~~~ Domain profile creation through local machine login
  990.         ElseIf (oNetwork.UserDomain = oNetwork.ComputerName and IsLocalUser(strUSER) = False and strDOMAIN <> "" and strDOMAIN <> oNetwork.ComputerName and strDOMAIN <> "." ) Then
  991.             
  992.             ' ~~~ Check if the profile exists for the domain user
  993.             If (GetSID(strUSER) <> "") Then
  994.                 ' ~~~ Set the return value as 7 to indicate the error
  995.                 IsValidInputs = Array("7")
  996.                 Exit Function
  997.             End If
  998.                 
  999.         ' ~~~ Domain profile creation through domain account login
  1000.         ElseIf (strDOMAIN <> "" and strDOMAIN <> oNetwork.ComputerName and strDOMAIN <> "." and IsLocalUser(strUSER) = False) Then    
  1001.             If IsDomainUser ( strUSER, strDOMAIN ) = False Then
  1002.                 IsValidInputs = Array("8")
  1003.                 Exit Function
  1004.             End If
  1005.             ' ~~~ Check if profile exists for the domain user
  1006.             If (GetSID(strUSER) <> "" ) Then
  1007.                 ' ~~~ Set the return value as 7 to indicate the error
  1008.                 IsValidInputs = Array("7")
  1009.                 Exit Function
  1010.             End If
  1011.             
  1012.         Else
  1013.             ' ~~~ return error 
  1014.             IsValidInputs = Array("5")
  1015.             Exit Function
  1016.         End If
  1017.         
  1018.     End If
  1019.     
  1020.     ' ~~~ Check for the drive validity
  1021.     If strDRIVE <> "" Then
  1022.         ' ~~~ Check if the drive is valid
  1023.         If IsValidDrive(strDRIVE) = False Then
  1024.             IsValidInputs = Array("4")
  1025.             Exit Function
  1026.         End If
  1027.     End If
  1028.     
  1029.     ' ~~~ return the inputs
  1030.     IsValidInputs = Array(strUSER, strPASS, strDOMAIN, strDRIVE)
  1031. End Function
  1032.  
  1033. ' ***
  1034. ' *** ------------------------------------------------------------------------------
  1035. ' *** Name:            IsDomainUser(sDOMUser,sDOMName)
  1036. ' *** ------------------------------------------------------------------------------
  1037. ' *** Purpose:        Returns true if the user is a domain member
  1038. ' *** ------------------------------------------------------------------------------
  1039. ' ***
  1040. Private Function IsDomainUser(sDOMUser,sDOMName)
  1041.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1042.     
  1043.     ' ~~~ Turn on error handling
  1044.     On Error Resume Next
  1045.     
  1046.     Dim oAccount 
  1047.     IsDomainUser = False
  1048.     
  1049.     ' ~~~ Account not in the machine, domain profile
  1050.     Set oAccount    = oWMIService.Get("Win32_UserAccount.Name='" & sDOMUser & "',Domain='" & sDOMName & "'")
  1051.     
  1052.     If NOT IsEmpty(oAccount) Then IsDomainUser = True
  1053.         
  1054.     Set oAccount = Nothing
  1055.     
  1056. End Function
  1057.  
  1058. ' ***
  1059. ' *** ------------------------------------------------------------------------------
  1060. ' *** Name:        IsInValidAccount(oUser)
  1061. ' *** ------------------------------------------------------------------------------
  1062. ' *** Purpose:    Checks if the user account is a valid account to be listed
  1063. ' *** ------------------------------------------------------------------------------
  1064. ' ***
  1065. Private Function IsInValidAccount(oUser)
  1066.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1067.  
  1068.     Dim sFive , sUserSID
  1069.     IsInValidAccount = False
  1070.  
  1071.     Select Case UCase(oUser.Name)
  1072.         Case "HELPASSISTANT"
  1073.             IsInValidAccount = True
  1074.         Case "ASPNET"
  1075.             IsInValidAccount = True
  1076.         Case "SUPPORT_388945A0"
  1077.             IsInValidAccount = True
  1078.         Case "SQLDEBUGGER"
  1079.             IsInValidAccount = True
  1080.         Case "ACTUSER"
  1081.             IsInValidAccount = True
  1082.         Case "IUSR_" & UCase(oNetwork.ComputerName)
  1083.             IsInValidAccount = True
  1084.         Case "IWAM_" & UCase(oNetwork.ComputerName)
  1085.             IsInValidAccount = True
  1086.         Case "VUSR_" & UCase(oNetwork.ComputerName)
  1087.             IsInValidAccount = True
  1088.         Case UCase(oNetwork.UserName)
  1089.             IsInValidAccount = True
  1090.         Case else
  1091.             If oUser.Get("PasswordExpired") <> 0 Then 
  1092.                 IsInValidAccount = True
  1093.             ElseIf IsUserLoggedOn(oUser) = True Then
  1094.                 IsInValidAccount = True
  1095.             End If
  1096.     End Select
  1097.     
  1098.     ' ~~~ Get the user SID 
  1099.     sUserSID = GetUserSID( oUser.Name )
  1100.     
  1101.     If Left(sUserSID,6) = "S-1-5-" AND Right(sUserSID,4) = "-500" Then
  1102.         ' ~~~ Administrator account
  1103.         IsInValidAccount = True
  1104.     ElseIf Left(sUserSID,6) = "S-1-5-" AND Right(sUserSID,4) = "-501" Then
  1105.         ' ~~~ Guest account
  1106.         IsInValidAccount = True
  1107.     End If
  1108.         
  1109.     
  1110. End Function
  1111.  
  1112. ' ***
  1113. ' *** ------------------------------------------------------------------------------
  1114. ' *** Name:            IsAccountLocked(oUser)
  1115. ' *** ------------------------------------------------------------------------------
  1116. ' *** Purpose:        Returns true if the specified account has a locked profile
  1117. ' *** ------------------------------------------------------------------------------
  1118. Private Function IsAccountLocked(oUser)
  1119.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1120.  
  1121.     Dim sProfilePath
  1122.  
  1123.     IsAccountLocked = False
  1124.  
  1125.     sProfilePath = oUser.Profile
  1126.  
  1127.     ' ~~~ If ProfilePath is blank, this account is not roaming and cannot be locked.
  1128.     If sProfilePath = "" Then Exit Function
  1129.  
  1130.     ' ~~~ Need error handling here - if the oFSo call below causes an error that's ok
  1131.     On Error Resume Next
  1132.  
  1133.     ' ~~~ If the ntuser.man exists within, then we have a locked account
  1134.     If oFSo.FileExists(sProfilePath & "\NTUSER.MAN") Then IsAccountLocked = True
  1135. End Function
  1136.  
  1137. End Class