Active Directory Scripting – a little trick for fail-safe automation
Reference page: Active Directory – Sample Scripts (Excel/VBA)
While processing User Account put the following code in the beginning of operations to disable it.
'Disable user account. objUser.AccountDisabled = True 'Save info On Error Resume Next objUser.SetInfo boolRC = (Err.Number <> 0) On Error GoTo 0 If boolRC Then 'recovery code End If
And enable it back once you’re successfully done.
'Enable user account objUser.AccountDisabled = False 'Save info On Error Resume Next objUser.SetInfo boolRC = (Err.Number <> 0) On Error GoTo 0 If boolRC Then 'recovery code End If
This way, in case of an unhandled exception that breaks execution of a script, any User Account that wasn’t properly processed will remain disabled and easily noticeable.
2 responses to "Active Directory Scripting – a little trick for fail-safe automation"
Sure this testers are paranoid! :)
[Albert’s Reply. We might seem paranoid at times but we’re not pessimistic!]
Great narrative, sweet and simple. Thanks!