Advertisement

10.30.2007 at 11:17AM PDT, ID: 22927792
[x]
Attachment Details

Disabling/Locking user account immediately

Asked by mcorrente in VB Script, Visual Basic Programming, Scripting Languages

Tags: user, account, disable

I've been tasked with writing a script to automatically log a user off a system and disable the user account following employment termination.  The problem I'm having is that the change is not filtering down fast enough.  A terminated employee will have time to walk down to the system and log back in before the workstation recognizes that the account is disabled.  I've tried a couple of things, this is the latest:

Const SHUTDOWN = 1
Const LOGOFF = 0
Const Reboot = 2
Const ForcedLogoff = 4
Const ForcedShutdown = 5
Const ForcedReboot = 6
Const PowerOff = 8
Const ForcedPowerOff = 12
Const ADS_UF_ACCOUNTDISABLE = 2
 
Set objUser = GetObject("LDAP://ADServer/cn=BadEmployee,cn=Users,dc=domain,dc=local")
intUAC = objUser.Get("userAccountControl")
 
objUser.SetPassword "YouAreFired"
objUser.Put "userAccountControl", intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo

strOption = ForcedLogoff
strComputer = "Workstation"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & strComputer & "\root\cimv2")
      
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
      ObjOperatingSystem.Win32Shutdown(strOption)
Next

This script changes the password, disables the account, and logs the user off the computer.  Works great, just not fast enough.  I added the password change thinking that it would recognize this change faster than the disabled, but no luck.  Tried shutting the system down hoping the delay would be enough, but no.  Any ideas how I can refresh this via script?

I'd prefer  using script, but I can throw this in a console application if anyone can solve it with VB...Start Free Trial
[+][-]10.30.2007 at 11:27AM PDT, ID: 20179674

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 11:49AM PDT, ID: 20179872

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 12:02PM PDT, ID: 20180021

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 12:08PM PDT, ID: 20180095

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 01:28PM PDT, ID: 20180847

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 03:55PM PDT, ID: 20181800

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.31.2007 at 07:16AM PDT, ID: 20185662

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:39PM PDT, ID: 20196469

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 10:29AM PST, ID: 20405066

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Visual Basic Programming, Scripting Languages
Tags: user, account, disable
Sign Up Now!
Solution Provided By: asawatzki
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628